Exits a procedure or block and transfers control immediately
to the statement following the procedure call or the block definition.
Statements
Exit Do: Immediately exits the Do loop in which it appears. Execution
continues with the statement following the Loop statement. Exit Do can be used
only inside a Do loop. When used within nested Do loops, Exit Do exits the
innermost loop and transfers control to the next higher level of nesting.
Exit For: Immediately exits the For loop in which it appears.
Execution continues with the statement following the Next statement. Exit For
can be used only inside a For...Next or For Each...Next loop. When used within
nested For loops, Exit For exits the innermost loop and transfers control to
the next higher level of nesting.
Exit Function: Immediately exits the Function procedure in which it
appears. Execution continues with the statement following the statement that
called the Function procedure. Exit Function can be used only inside a Function
procedure.To specify a return value, you can assign the value to the
function name on a line before the Exit Function statement. To assign the
return value and exit the function in one statement, you can instead use the
Return Statement (Visual Basic).
Exit Property: Immediately exits the Property procedure in which it
appears. Execution continues with the statement that called the Property
procedure, that is, with the statement requesting or setting the property's
value. Exit Property can be used only inside a property's Get or Set procedure.
To specify a return value in a Get procedure, you can assign
the value to the function name on a line before the Exit Property statement. To
assign the return value and exit the Get procedure in one statement, you can
instead use the Return statement. In a Set procedure, the Exit Property statement is
equivalent to the Return statement.
Exit Select: Immediately exits the Select Case block in which it appears.
Execution continues with the statement following the End Select statement. Exit
Select can be used only inside a Select Case statement.
Exit Sub: Immediately exits the Sub procedure in which it appears.
Execution continues with the statement following the statement that called the
Subprocedure. Exit Sub can be used only inside a Sub procedure.
In a Sub procedure, the Exit Sub statement is equivalent to
the Return statement.
Exit Try: Immediately exits the Try or Catch block in which it
appears. Execution continues with the Finally block if there is one, or with
the statement following the End Try statement otherwise. Exit Try can be used
only inside a Try or Catch block, and not inside a Finally block.
Exit While: Immediately exits the While loop in which it appears.
Execution continues with the statement following the End While statement. Exit
Whilecan be used only inside a While loop. When used within nested While loops,
Exit While transfers control to the loop that is one nested level above the
loop where Exit While occurs.
Note: Do not confuse Exit statements with End statements. Exit
does not define the end of a statement.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.