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

Create dynamic variables

Status
Not open for further replies.

mainmast

Programmer
Jun 26, 2003
176
0
0
US
I'm using the same script in this post: thread333-1208172

I need to be able to dynamically create variables based off of what "Foo" contains in that script posted by Sheco at the end. Is that possible?
 
Code:
<%
Dim Foo
Dim Bar()
Dim Indx
Indx = 0
For Each Foo in Request.Form
  Bar(Indx) = Request.Form(Foo)
  Response.Write Foo & " = " & Request.Form(Foo)
  Response.Write "<br>" & vbCrLf
  Indx = Indx + 1
Next
%>

There you go - all in a nice array!

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
You can create stuff off foo within the loop but not outside the loop.

Say you have a collection with n+1 items. You can iterate through the collection like
Code:
for i = 0 to n
   set foo = coll(i)
   ... do something
next
What for each does is it gets rid of you having to count up how many items you have. In the above example, you lose i and n.
Code:
for each foo in coll
   ... do something
next
You can create stuff from foo in ... do something.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top