Goto If RaiseEvent Branching Statements

55 Exits a function. Execution continues with the first statement following the statement that called the function. Exit Property Exits a property get or property set procedure. Execution continues with the first statement following the statement that invoked the property get or property set procedure. Exit Sub Exits a subroutine. Execution continues with the first statement following the statement that called the subroutine. Exit Try Exits the Try clause of a Try block. If the Try block has a Finally clause, execution continues with the first statement in the Finally clause. If the Try block does not have a Finally clause, execution continues with the first statement following the Try block.

2.13.2.3 Goto

The Goto statement transfers execution to the first statement following the specified label. For example: ... Goto MyLabel ... MyLabel: ... The label must be in the same procedure as the Goto statement. The Goto statement is generally avoided in structured programming because it often leads to code that is difficult to read and debug.

2.13.2.4 If

The If statement controls whether a block of code is executed based on some condition. The simplest form of the If statement is: If expression Then statements End If expression is any expression that can be interpreted as a Boolean value. If expression is True , the statements within the If block are executed. If expression is False , those statements are skipped. To provide an alternative set of statements to execute when expression is False , add an Else clause, as shown here: If expression Then statements Else statements 56 End If If expression is True , only the statements in the If clause are executed. If expression is False , only the statements in the Else clause are executed. Finally, a sequence of expressions can be evaluated by including one or more ElseIf clauses, as shown here: If expression Then statements ElseIf expression Then statements ElseIf expression Then statements Else statements End If The first If or ElseIf clause whose expression evaluates to True will have its statements executed. Statements in subsequent ElseIf clauses will not be executed, even if their corresponding expressions are also True . If none of the expressions evaluate to True , the statements in the Else clause will be executed. The Else clause can be omitted if desired.

2.13.2.5 RaiseEvent

The RaiseEvent statement fires the given event. After the event has been fired to all listeners, execution continues with the first statement following the RaiseEvent statement. See Sect ion 2.20 later in this chapter for more information.

2.13.2.6 Return