# Use a variable to identify a variable

Is there a way to use a variable to identify a variable-- for example:

Value1ID as integer
Value2ID as integer
Value3ID as integer

For x=1 to 3
Value & x & ID = 123*x
Next x
###### Who is Participating?

Commented:
Use a two-dimensional array

Dim ValueID(3)(3) as integer
0

Commented:
use an array:

Dim ValueID(3) as Integer

For x=1 to 3
ValueID(x) = 123*x
Next x

AW
0

Commented:
Hi kevman123,

Use an array:

Dim ValueID(3) as Integer

For x = 1 to 3
ValueID(x-1) = 123*x
Next x

bkt
0

Commented:
Gah!  Sorry AW.
Too slow.
0

Author Commented:
That's the problem, it is already an array- sorry I forgot to put that-

Value1ID(3) as integer
Value2ID(3) as integer
Value3ID(3) as integer

For x=1 to 3
Value & x & ID(x) = 123*x
Next x
0

Author Commented:
I guess I could use a 2 dimensional array- however, I would like to know if my original question is possible, not just a workaround.
0

Author Commented:
We're on the same wavelength!
0

Commented:
Using arrays is the only way I know of doing that in VB.
0

Author Commented:
Ok- I'll hold out for a little bit and see if anyone has an answer for it- otherwise I'll just give you the points since you gave the most feedback-
0

Commented:
No, your original idea will not work.  You could however define a Class to hold an array of Items, and then create an array of instances of your class - which is functionally identical to a two-dimensional array.  But that is NOT the same thing as the idea you asked about in the original question.  The problem with:

Value & x & ID(x)

is that there is no 'variable' defined in you code for 'Value", and by using the & operator, the resultant entity would be a STRING, and not the NAME of a variable - and in any case, the Name of a variable and the VARIABLE itself are not the same thing.

Consider the famous painting of a PIPE, which is labeld "This is NOT a PIPE" (it is not a PIPE, because it is a PAINTING of a PIPE and thus, as such, is nothing more that a REPRESENTATION of a PIPE and not the PIPE itself)

Similarly, if you were to be arrested and then convicterd, the authorities would not throw your NAME in jail, they would throw YOU - your PHYSICAL self - in jail.

AW
0

Author Commented:
I believe a split is in order here- thanks for the quick responses guys!
0

Author Commented:
Well, I should have reversed the assisted and accepted answers- anyhow- thanks again-
0

Commented:
as long as the points were assigned the same, Accepted and Assisted are irrrelevant.  And as for the points, with just 9,900,000 more, I can get a Tall Mocha Latte at Starbucks for only \$4.50  LOL.

AW
0

Commented:
AW, agreed.

>ust 9,900,000 more...   ROFL
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.