0

How to I rearrange this so that only distance less than or equal to 25 are displayed?

For i = 1 to 20
               Display(rs)
               rs.MoveNext
               If rs.Eof Then Exit For
               If rs("distance")>25 Then Exit For
            Next
4
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by ctj
0

first thing i noticed is that your comparison sign is incorrect:

If rs("distance")>25 Then Exit For

should be

If rs("distance")<25 Then Exit For

I would also change the loop, to loop till end of file instead of using the counter i, what if the records that are less than 25 are in the fileds that are not extracted by your counter.

Hope this helps a bit.

0

Nearly, should be...

If rs("distance")<=25 Then Exit For

...for less than or equal to. :o)

If I understand the original question, then both these response seem incorrect. My interpretation of your response is that the "loop" will stop at the first occurence of a distance < 25. The poster seem to be asking for loop that will display only distants under 25, which I interpret as " show me all the distants that are < 25.

Therefore, he must use something such as :

do while not rs.eof
if rs("distant")<25 then
response.write " display me" ' or whatever he wants to do
end if
rs.movenext
loop

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.