dynamically dim a variable ie dim "variable"&n 
Author Message
 dynamically dim a variable ie dim "variable"&n

I'm trying to dim a variable that I am creating so I can pass it
between functions only I can't seem to do it. Is this even the best
way of doing it???

I've tried numerouse eval type commands  but haven't managed to work
it out.

any help would be much appreciated, I basically want to dim a variable
called "visitpages"&n where n is an integer.

Thanks again,
            Mike.



Sat, 25 Sep 2004 19:00:18 GMT  
 dynamically dim a variable ie dim "variable"&n
Good evening from Seoul.

I'm not sure what you want exactly. Anyway, try /execute/ instead of /eval/.

for i=1 to 3
execute "x" & i & "=" & i
next
msgbox x2

--
Han
Seoul, Korea


Quote:
> I'm trying to dim a variable that I am creating so I can pass it
> between functions only I can't seem to do it. Is this even the best
> way of doing it???

> I've tried numerouse eval type commands  but haven't managed to work
> it out.

> any help would be much appreciated, I basically want to dim a variable
> called "visitpages"&n where n is an integer.

> Thanks again,
>             Mike.



Sat, 25 Sep 2004 20:22:02 GMT  
 dynamically dim a variable ie dim "variable"&n

bar1 = "blah"
n = 1

foo eval("bar" & n)

sub foo(arg)
  msgbox arg
end sub

Note that using arrays is probably a better solution to whatever the *real* problem is (which you never really stated ;-)...

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--

Quote:

> I'm trying to dim a variable that I am creating so I can pass it
> between functions only I can't seem to do it. Is this even the best
> way of doing it???

> I've tried numerouse eval type commands  but haven't managed to work
> it out.

> any help would be much appreciated, I basically want to dim a variable
> called "visitpages"&n where n is an integer.

> Thanks again,
>             Mike.



Sun, 26 Sep 2004 03:23:17 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Loop print "VARIABLE", "VARIABLE"

2. "late" DIM statements

3. PROB with "dim as new ADODB...."

4. Problem with "Dim as Field"

5. "Un-dim" Array

6. PROB with "dim as new ADODB...."

7. What is "Dim X%"?

8. PROB with "dim as new ADODB...."

9. Problem with "Dim as Field"

10. VB7 and "Dim WebPublic"

11. there is a variables when i dim a dynamic array

12. dim variable as date?

 

 
Powered by phpBB® Forum Software