RSS Forums RSS
Please support our ASP advertiser: Lunarpages ASP Web Hosting
Views: 1217 | Replies: 3
Reply
Join Date: May 2008
Posts: 1
Reputation: pit1031 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
pit1031 pit1031 is offline Offline
Newbie Poster

For Loop

  #1  
May 2nd, 2008
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
Last edited by peter_budo : May 3rd, 2008 at 7:42 pm. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2008
Posts: 117
Reputation: Thirusha is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 13
Thirusha Thirusha is offline Offline
Junior Poster

Re: For Loop

  #2  
May 5th, 2008
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.
Reply With Quote  
Join Date: Apr 2008
Posts: 11
Reputation: webthang_rob is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
webthang_rob webthang_rob is offline Offline
Newbie Poster

Re: For Loop

  #3  
May 8th, 2008
Nearly, should be...

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

...for less than or equal to. :o)
Reply With Quote  
Join Date: Mar 2008
Posts: 2
Reputation: ctj is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ctj ctj is offline Offline
Newbie Poster

Re: For Loop

  #4  
May 20th, 2008
Originally Posted by webthang_rob View Post
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
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 11:32 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC