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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a variable value in a new variable name

Status
Not open for further replies.

kev510

Programmer
Jul 12, 2006
61
Hello everyone!
I am once again stuck... using VBScript.
I am trying to dynamically create the following list:

vVariable1 = 1
vVariable2 = 2
vVariable3 = 3
vVariable4 = 4

using:
for i = 1 to 3
vVariable(insert i value here) = (insert i value here)
next

I've tried all sorts of things for about 15-25 minutes with no luck. Thanks for any help!

-Kev
 
Why not using an array ?
If you insist:
For i = 1 To 3
Execute "vVariable" & i & " = " & i
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for your response!

How would you response.write the value?

Again, dynamically like this:

for i = 1 to 3
<%=vVariable(insert i value here)%>
next
 
oops, that's meant to be

<%for i = 1 to 3%>
<td><%=vVariable(insert i value here)%></td>
<%next%>

(simplified)
 
Again, why not using an array ?
If you insist, have a look at the Eval function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
yeap PHV is on the money here. Whilst I have thought writing suedo code with Execute is indeed interesting arrays/dictionary of objects etc should be more than enough for your needs
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top