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

Newbie asp question

Status
Not open for further replies.

Dzeromas

Technical User
Jul 16, 2003
12
SI
Hello
Let's say I've got a string variables data1,data2,data3...
i=1
do while i < 5
f.writeline(data + i) //<--???
//How must I put the quotes that all
//variables(data1...dataN)contents
//will be written to a file f
i=i+1
Loop
 
I've already tried this but it doesn't work.
It only writes the value of i.
 
It looks I wasn't clear enough.
data1<--this one is for i=1
data2<--this one is for i=2
datai<--this one is for i
Instead of writing every data1..dataN,
I want to use i to stick to data
Example:
Instead of f.writeline(data1)
I would like to somehow stick i and data together.
When i=1 I want to write datai,which would be the same as data1.
 
I would think you would be better off using an array for this:
Code:
Dim data(4)
data(0) = &quot;something&quot;
data(1) = &quot;something more&quot;
data(2) = &quot;you get the point&quot;
data(3) = &quot;red rover red rover&quot;
data(4) = &quot;I hate making up fake variables :P&quot;

Dim i
For i = 0 to 4
   response.Write data(i) & &quot;<br>&quot;
Next

If you absolutely must use variables with appended numbers and then loop through them, you could use the Execute() method:
Code:
For i = 1 to 5
   Execute(&quot;Response.Write data&quot; & i)
Next

Execute basically evaluates a string and then executes it as a line of code, so that would be another possible solution for your problem.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Thank you very much Tarwn.
I used the second option(which is better for my program structure) and it helped. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top