From: ll on
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
From: Bob Barrows [MVP] on
ll wrote:
> 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) ...


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 | 
Pages: 1
Prev: persist session info
Next: REDIM Preserve problem