Syntax
| Exit {All|Do|For|Function|Property|Sub|While}
| ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description
| The exit instruction causes the macro to continue with out doing some or all of the remaining instructions.
| ||||||||||||||||
See Also
| |||||||||||||||||
Example
| Sub Main
L$ = InputBox$("Enter Do, For, While, Sub or All:")
Debug.Print "Before DoSub"
DoSub UCase$(L$)
Debug.Print "After DoSub"
End Sub
Sub DoSub(L$)
Do
If L$ = "DO" Then Exit Do
I = I+1
Loop While I < 10
If I = 0 Then Debug.Print "Do was entered"
For I = 1 To 10
If L$ = "FOR" Then Exit For
Next I
If I = 1 Then Debug.Print "For was entered"
I = 10
While I > 0
If L$ = "WHILE" Then Exit While
I = I-1
Wend
If I = 10 Then Debug.Print "While was entered"
If L$ = "SUB" Then Exit Sub
Debug.Print "Sub was not entered."
If L$ = "ALL" Then Exit All
Debug.Print "All was not entered."
End Sub
|