Name
Exit Statement
Syntax
Exit Do Exit For Exit Function Exit Property Exit Select Exit Sub Exit Try Exit While
Description
Prematurely exits a block of code
Rules at a Glance
-
Exit
Do
Exits a
Do...Loop
statement. If the currentDo...Loop
is within a nestedDo...Loop
, execution continues with the nextLoop
statement wrapped around the current one. If, however, theDo...Loop
is standalone, program execution continues with the first line of code after theLoop
statement.-
Exit
For
Exits a
For...Next
loop or aFor
Each...Next
statement. If the currentFor...Next
is within a nestedFor...Next
loop, execution continues with the nextNext
statement wrapped around the current one. If, however, theFor...Next
loop is standalone, program execution continues with the first line of code after theNext
statement.-
Exit
Function
Exits the current function. Program execution is passed to the line following the call to the function.
-
Exit
Property
Exits the current property procedure. Program execution is passed to the line following the call to the property.
-
Exit
Select
Immediately exits a
Select
Case
construct. Execution continues with the statement immediately following theEnd
Select
statement.-
Exit
Sub
Exits the current sub procedure. Program execution is passed to the line following the call to the procedure.
-
Exit
Try
Immediately exits a
Try...Catch
block. Program execution proceeds with theFinally
block, if it is present, or with the statement following theEnd
Try
statement.-
Exit
While ...
Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.