Microsoft® Visual Basic® Scripting Edition
Exit Statement
| Language Reference 
| Home | Site Map |

 

See Also


Description
Exits a block of Do...Loop, For...Next, Function, or Sub code.

Syntax

Exit Do

Exit For

Exit Function

Exit Sub

The Exit statement syntax has these forms:

StatementDescription
Exit DoProvides a way to exit a Do...Loop statement. It can be used only inside a Do...Loop statement. Exit Do transfers control to the statement following the Loop statement. When used within nested Do...Loop statements, Exit Do transfers control to the loop that is one nested level above the loop where it occurs.
Exit ForProvides a way to exit a For loop. It can be used only in a For...Next or ForEach...Next loop. Exit For transfers control to the statement following the Next statement. When used within nested For loops, Exit For transfers control to the loop that is one nested level above the loop where it occurs.
Exit FunctionImmediately exits the Function procedure in which it appears. Execution continues with the statement following the statement that called the Function.
Exit SubImmediately exits the Sub procedure in which it appears. Execution continues with the statement following the statement that called the Sub.


© 1996 by Microsoft Corporation.