Convert from string to variable??

Davidii111

New member
Joined
Nov 9, 2009
Messages
4
Programming Experience
Beginner
sRndMessageNumber = "sNewMessage" & CInt(Int((3 - 1 + 1) * Rnd() + 1))

I want to Calculate a number between 1 to 3 and then call the variable sNewMessage2 for example. So how to convert from string to variable? :S
 
You can use an array (or a List), these can be indexed.
VB.NET:
Dim strings() As String = {"a", "b", "c"}
Dim rnd As New Random
Dim randomMessage As String = strings(rnd.Next(0, 3))
 
Yea but i still get the value in string format right? if i get for example sNewMessage2 then i want to call the variable sNewMessage2 and get the values that are inside that variable..sorry if im wrong. /david
 
You can create an array of any type you want, it is no different than having two or more single variables.
 
Back
Top