Exit Statement

Exit { Do | For | Function | Sub }

Exits a loop or procedure.

Example:

' This sample shows Do...Loop with Exit Do to get out.

 

Sub Main()

   Dim Value, Msg   ' Declare variables.

   Do

       Value = InputBox("Enter a value from 5 to 10.")

       If Value >= 5 And Value <= 10 Then   ' Check range.

           Exit Do   ' Exit Do...Loop.

       Else

           Beep   ' Beep if not in range.

       End If

   Loop

End Sub

 


Related Topics:

End Statement

Stop Statement