f



Variables in Variable Name

The most basic way to ask my question if there is anyway of doing this
would be a program that did:

Dim test1 = 1
Dim test2 = 2
Dim test3 = 3

for i = 1 to 3
    print testi
next i

Well this presents problems because it wont treat the i as a number,
is there anyway of doing this? Thank you.
0
erickit (3)
1/26/2004 5:42:10 PM
comp.lang.basic.visual.misc 10153 articles. 0 followers. Post Follow

2 Replies
757 Views

Similar Articles

[PageSpeed] 14

Eric wrote:
> 
> The most basic way to ask my question if there is anyway of doing this
> would be a program that did:
> 
> Dim test1 = 1
> Dim test2 = 2
> Dim test3 = 3
> 
> for i = 1 to 3
>     print testi
> next i

You were close; all you need is brackets:

dim test(3) as integer
test(1) = 1
test(2) = 2
test(3) = 3

for i = 1 to 3
     print test(i)
next i

> 
> Well this presents problems because it wont treat the i as a number,
> is there anyway of doing this? Thank you.
0
ruthal (141)
1/26/2004 5:57:56 PM
"Eric" <erickit@bellsouth.net> wrote in message
news:bd7ac0c8.0401260942.bdbdac6@posting.google.com...
> The most basic way to ask my question if there is anyway of doing this
> would be a program that did:
>
> Dim test1 = 1
> Dim test2 = 2
> Dim test3 = 3
>
> for i = 1 to 3
>     print testi
> next i
>
> Well this presents problems because it wont treat the i as a number,
> is there anyway of doing this? Thank you.

Not sure of the exact dialect you're looking for but:

DIM test (1 to 3)
test(1)=1
test(2)=2
test(3)=3

for i = 1 to 3
    print test(i)
next i

HK

0
1/26/2004 6:04:24 PM
Reply: