Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating variable names on the fly

Status
Not open for further replies.
Apr 27, 1999
705
US


Hi,

Instead of using an array, I'm trying to create variable names in a for loop such as Q1, Q2, Q3, Q4...etc.

I know this doesn't work b
For I = 1 to 10
"Q" & cstr(i) = I ' I know this doesn't work but
its logically what I want to do.
Next

Results should be
Q1 = 1
Q2 = 2
Q3 = 3

Thanks,
fengshui_1998
fengshui_1998
 
Hi fengshui,
use the execute statement

syntax unsure
eg
execute("dim act"&x)
execute("vart" & x & "=string")




_________________________________________________________
$str = "sleep is good for you. sleep gives you the energy you need to function";
$Nstr = ereg_replace("sleep","coffee",$str); echo $Nstr;

onpnt2.gif
[/sub]
 
Onpt,

Thanks for the suggestion. I'll try it and see if it works.

fengshui_1998
 
Onpt,

FYI

This works:

I = 5
execute("Q" & cstr(I) ) & " = 5"
msgbox Q5

Q5 = 5

Thanks!
fengshui_1998
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top