hi.
at first: i'm sorry for my poor english.
i want to Convert a string into a varibale like these:
dim a as string="this text must be show"

dim b as string="a"
'in my application b's value read from an excel sheet and must point to a variable that exist in my application.

now i want to Convert b's value to the variable that already exist in my application with name a (tha store in b) somthing like dim c as string=pointer to b's value and the when i use msgbox(a) program will show me this message "this text must be show".
can anybody help me?
thanks.

Do you mean something like this (VBA)?

Sub HelloWorld()
   Dim a As String
   Dim b As String
      
   a = "Hello World"
   b = a
   
   ActiveCell.FormulaR1C1 = b
End Sub

You can also use your string variable in a MsgBox. The simplest example being: MsgBox(b)
Of course you can modify this as you like. I'm just giving the simplest example I can think of...

Look what I understand you need to assign variable to another value

Dim value1 as string
Dim value2 as string
value1 = "value1"
value2 = "value2"
value2 = value1
MessageBox.Show(value2) 'shows value1

Do you mean something like this (VBA)?

Sub HelloWorld()
   Dim a As String
   Dim b As String
      
   a = "Hello World"
   b = a
   
   ActiveCell.FormulaR1C1 = b
End Sub

You can also use your string variable in a MsgBox. The simplest example being: MsgBox(b)
Of course you can modify this as you like. I'm just giving the simplest example I can think of...

no. it's not like it at all. why i even need b variable in your code ?
and you put b values ("Heelo world" in excel sheet i don't want that. of course you didn't get that because of my english. but i want this: i readed some string that containes 'a' from excel and store in b vaiable. now i want to use b variable to access (a) variable or whatever i put in the excel. so for example if i changed excel data to myvar2 and rerun my program then data stored in b variable will be "myvar2" now i want to access myvar2 in my prog throw b's.:icon_sad: i don't know hot to explain any more

read some string that containes 'a' from excel and store in b

Dim b As String
b = Cells(1, 1)

now i want to use b variable to access whatever i put in the excel. so 'for example if i changed excel data to myvar2 and rerun my program 'then data stored in b variable will be "myvar2"

b = Cells(1, 1) just grabs whatever is in that cell, if you change it and rerun the program it will have the current value of cell(1,1), if the contents is "myvar2" then b will be that value as well

now i want to access myvar2 in my prog throw b's.:icon_sad: i don't know hot to explain any more

I'm not sure what you mean here, but you have the string "myvar2" in the variable b so you can use it as you would any other string. I'm sorry if I'm no help at all. I'm trying my best to answer as I can.

Do you mean something like that?

Dim A1 = "Message1"
Dim A2 = "Message2"
Dim A3 = "Message3"

Dim B
B = "A1"
MsgBox(B) <-- should show "Message1"

B = "A2"
MsgBox(B) <-- should show "Message2"

etc ... ?

Do you mean something like that?

Dim A1 = "Message1"
Dim A2 = "Message2"
Dim A3 = "Message3"

Dim B
B = "A1"
MsgBox(B) <-- should show "Message1"

B = "A2"
MsgBox(B) <-- should show "Message2"

etc ... ?

Exactly thanx. (also thanks every body else whom posted before to helping me out). now is there any way to to this ?

and also i can put my variables name in a hashtable and using them from that like :
dim MyVar1 as string="Hello"
dim MyVar2 as string="MyVar1"

Dim MyHashTable As New Hashtable
MyHashTable.Add("MyVar1",MyVar1)
msgbox(MyHashTable.Item(MyVar2)
and msgbox will show the Hello world but i want to do that without hashtables or some trick like that because it's very important for my program using minimal resources as possible and i have too many variables .so ... ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.