[thelist] ASP For next Loop - help

Ken Schaefer Ken at adOpenStatic.com
Mon Jul 10 18:17:49 CDT 2006


Is there a question here? :-) What do you /want/ the code to do? I.e. what is
it supposed to do. It obviously runs as it has been programmed to, but the
result it is outputting isn't what you want. So, what do you want?

That said, for each record in rsServerList you are then looping through the
entire ServicesArray. Is that what you want?

Secondly, attaching a debugger and stepping through the code would allow you
to see exactly what code path is being followed, and what the values of your
variables are. That way, you can see why a certain equality (If
mid(rsServiceList("ID"),2,36) = ServicesArray(Icounter) Then) condition is
always being met.

And this type of code looks like a maintainability nightmare. Have you
considering writing some generic functions to handle your form elements (or,
better, written some classes to handle this for you?)

Cheers
Ken

--
My IIS Blog: www.adOpenStatic.com/cs/blogs/ken
Tech.Ed Sydney: learn all about IIS 7.0 - See you there!

: -----Original Message-----
: From: thelist-bounces at lists.evolt.org [mailto:thelist-
: bounces at lists.evolt.org] On Behalf Of Brian Delaney
: Sent: Tuesday, 11 July 2006 5:45 AM
: To: thelist at lists.evolt.org
: Subject: [thelist] ASP For next Loop - help
: 
: For some reason, this For loop always repeats the first element. Which
: returns a true
: 
: Do While Not rsServiceList.EOF
:                        For Icounter = 0 to iarraysize
:                        IF mid(rsServiceList("ID"),2,36) =
: ServicesArray(Icounter) Then
:                               servicelistHTML = servicelistHTML &
: "<input id=checkboxs type=checkbox value= " &
: mid(rsServiceList("ID"),2,36) & " name=checkboxs
:          checked>&nbsp;&nbsp;"
:                             servicelistHTML = servicelistHTML &
: rsServiceList("Name") & "<br>"
:                             vtrue = true
:                      else
:                             vtrue = false
:                         end if
:                     Next
:                     if vtrue <> true then
:                                servicelistHTML = servicelistHTML &
: "<input id=checkboxs type=checkbox value= " &
: mid(rsServiceList("ID"),2,36) & "
:                                 name=checkboxs>&nbsp;&nbsp;"
:                                 servicelistHTML = servicelistHTML &
: rsServiceList("Name") & "<br>"
:                     end if
:             vtrue = ""
:    rsServiceList.MoveNext
:   Loop
: 




More information about the thelist mailing list