Back to index

Exit Statement
Exits a procedure or block and transfers control immediately to the statement following the procedure call or the block definition.

Format:

 Exit { Do | For | Function | Select | Sub | While }

Syntax:

Remarks:

1. Do not confuse Exit statements with End statements. Exit does not define the end of a statement.

See also:

- Do...Loop statements
- For...Next statements
- Function statements
- Stop statement
- Sub statement

Example:

   Sub ExitStatementDemo()
      Do ' Set up infinite loop.
         For I = 1 To 1000   ' Loop 1000 times.
            MyNum = Int(Rnd * 100)   ' Generate random numbers.
            Select Case MyNum   ' Evaluate random number.
               Case 7: Exit For   ' If 7, exit For...Next.
               Case 29: Exit Do   ' If 29, exit Do...Loop.
               Case 54: Exit Sub   ' If 54, exit Sub procedure.
            End Select
         Next I
      Loop
   End Sub


Copyright (c) 2000-2006 by Smartphoneware. All rights reserved.