faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

How can I get this to work: str = txt(n).value where n is an incremental number within a loop?

Mar 23rd, 2004 00:13
Jason Benson, Mandy Anderson,


<%
DIM txt(5) 'declare the array

txt(0) = "potatoes"
txt(1) = "apples"
txt(2) = "oranges"
txt(3) = "bananas"
txt(4) = "pears"
txt(5) = "peaches"

for n = 0 to 5

Response.Write txt(n) & VBCRLF

Next
%>

Will output:

potatoes
apples
oranges
bananas
pears
peaches

If you just wanted to write "n" then
<% for n = 0 to 5

Response.Write n & VBCRLF
Next
%>

Will output:
0
1
2
4
5

if like in your question you want to make a String Variable = to the 
value in the above array:

<% for n = 0 to 5

StrVar = StrVar & n & VBCRLF
Next

Response.Write StrVar
%>

will output
0
1
2
3
4
5


hope that helps
jb

"It is a mistake to think you can solve any major problems just with 
potatoes."
--Douglas Adams



© 1999-2004 Synop Pty Ltd