Exit (statement)

<< Click to Display Table of Contents >>

Exit (statement)

Exit {Do|For|Function|Sub}

Exits from a Do loop, a For loop, a function, or a procedure.

See also: End, Stop

Example:

Sub Main

 Dim Value, Msg

 Do

         Value = InputBox("Enter a number between 5 and 10.")

         If Value >= 5 And Value <= 10 Then

                 Exit Do      ' Number is OK -> Exit from the loop

         Else

                 Beep         ' Number is not OK -> try once more

         End If

 Loop

End Sub