Control flow statements modify the flow of execution in a method. There are five control flow statements:
GoTo
statement causes execution to transfer to the specified label in the method.Exit
statement transfers execution to the next statement after the end of the immediately containing block statement of the specified kind. If the block is the method block, then execution is transferred back to the expression that invoked the method. If the Exit
statement is not contained within the kind of block specified in the statement, a compile time error occurs.Stop
statement causes a debugger exception to occur.End
statement causes the program to terminate. End is equivalent to throwing an uncatchable exception. This statement may not be used in programs that are not executable (for example, DLLs).Return
statement returns execution to the expression that invoked the method. If the method is a subroutine, the statement is equivalent to an Exit
Sub
statement and no expression may be supplied. If the method is a function, an expression must be supplied that is implicitly convertible to the return type of the function; this form is equivalent to assigning to the function return local and then executing an Exit
Function
statement.GoTo
LabelName StatementTerminatorExit
ExitKind StatementTerminatorDo
| For
| Sub
| Function
| Property
| Try
Stop
StatementTerminatorEnd
StatementTerminatorReturn
[ Expression ]