Recoding with Loop

L

ll

I'm working in ASP, and I'm trying to refine a site I inherited. In
particular, there was code that looked like this (it checked for 15
different variables, doing it one at a time, "hardcoded," rather than
through a loop):

'-----------------------------------------------------------
if strOut1 <> "" then
If strOut1 = "N/A" then
strOut1 = "&nbsp; "
else
strOut1 = strOut1 & ","
end if
end if


if strOut2 <> "" then
If strOut2 = "N/A" then
strOut2 = "&nbsp; "
else
strOut2 = strOut2 & ","
end if
end if
'-----------------------------------------------------------

.....and so on.........until we get to strOut15

I'm looking at doing this through a loop and was wondering what the
best way would be? Here's what I have so far:

'-----------------------------------------------------------
for a=1 to 15
if "strOut"&a <> "" then
If "strOut"&a = "N/A" then
strOut(a)="&nbsp;"
else
strOut(a) = "strOut"&a & ","
end if
else
strOut(a) = ""
end if
next
'-----------------------------------------------------------

Thanks for any help. Regards - Louis
 
B

Bob Barrows [MVP]

ll said:
I'm working in ASP, and I'm trying to refine a site I inherited. In
particular, there was code that looked like this (it checked for 15
different variables, doing it one at a time, "hardcoded," rather than
through a loop):

'-----------------------------------------------------------
if strOut1 <> "" then
If strOut1 = "N/A" then
strOut1 = "&nbsp; "
else
strOut1 = strOut1 & ","
end if
end if


if strOut2 <> "" then
If strOut2 = "N/A" then
strOut2 = "&nbsp; "
else
strOut2 = strOut2 & ","
end if
end if
'-----------------------------------------------------------

....and so on.........until we get to strOut15

I'm looking at doing this through a loop and was wondering what the
best way would be? Here's what I have so far:

'-----------------------------------------------------------
for a=1 to 15
if "strOut"&a <> "" then
If "strOut"&a = "N/A" then
strOut(a)="&nbsp;"
else
strOut(a) = "strOut"&a & ","
end if
else
strOut(a) = ""
end if
next
'-----------------------------------------------------------

Thanks for any help. Regards - Louis

Put the values into an array then loop through the array:
strout=array(strout1,...,strout15)
for a = 0 to 14
if strout(a) ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top