Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Why can't I "Exit While"?

Posted on 2003-03-31
Medium Priority
Last Modified: 2012-08-13
Fairly self-explanitory and I'm sure an easy question.  Example:

while rsTest.EOF = False
    if rsTest!id = 1 then exit while

According to Microsoft, from the MSDN VB6 reference for the "Exit" keyword:

Immediately exits the While loop in which it appears. Execution continues with the statement following the End While statement...."

So why, when I use "Exit While" does VB say "Syntax Error"?  If I can't use it (why would MS say I can?) what alternative can I use?  (I hate goto's but will use them if I have to)

(oh, VB6/SP5/W2000)
Question by:tomrwilson
  • 2
LVL 10

Accepted Solution

aeklund earned 400 total points
ID: 8241241
You can change your loop to a do..loop

do until rrTest.EOF
  if rsTest!id = 1 then exit do
LVL 70

Expert Comment

by:Éric Moreau
ID: 8241284
because it is an old syntax that can be replaced with :

do while rsTest.EOF = False
    if rsTest!id = 1 then exit do

Author Comment

ID: 8241634
Duh. :)  Thanks (to both).  Sorry to the other commenter, I picked the answer posted first.
LVL 10

Expert Comment

ID: 8241785
Glad to help...

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question