Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Use a variable to identify a variable

Posted on 2004-08-03
14
Medium Priority
?
233 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:kevman123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 3
14 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 11705237
use an array:

Dim ValueID(3) as Integer

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


AW
0
 
LVL 6

Expert Comment

by:bkthompson2112
ID: 11705267
Hi kevman123,

Use an array:

Dim ValueID(3) as Integer

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

bkt
0
 
LVL 6

Expert Comment

by:bkthompson2112
ID: 11705275
Gah!  Sorry AW.
Too slow.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kevman123
ID: 11705281
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
 
LVL 6

Accepted Solution

by:
bkthompson2112 earned 1000 total points
ID: 11705341
Use a two-dimensional array

Dim ValueID(3)(3) as integer
0
 

Author Comment

by:kevman123
ID: 11705342
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 Comment

by:kevman123
ID: 11705348
We're on the same wavelength!
0
 
LVL 6

Expert Comment

by:bkthompson2112
ID: 11705550
Using arrays is the only way I know of doing that in VB.
0
 

Author Comment

by:kevman123
ID: 11705570
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
 
LVL 44

Assisted Solution

by:Arthur_Wood
Arthur_Wood earned 1000 total points
ID: 11705603
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 Comment

by:kevman123
ID: 11705679
I believe a split is in order here- thanks for the quick responses guys!
0
 

Author Comment

by:kevman123
ID: 11705695
Well, I should have reversed the assisted and accepted answers- anyhow- thanks again-
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 11708751
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
 
LVL 6

Expert Comment

by:bkthompson2112
ID: 11708842
AW, agreed.

>ust 9,900,000 more...   ROFL
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question