CitectVBA Programming Reference > Understanding CitectVBA Language Basics > Control Structures > GoTo statement

GoTo statement

The GoTo conditional statement branches unconditionally and without return to the label specified in the GoTo statement. The label must be located in the same subroutine or function as the Goto statement.

<statement/s>
If <condition> then
GoToLabel1
Else
GoToLabel2
End If
Label1:
<statement/s>
GoToLabel3
Label2:
<statement/s>
GoToLabel3
Label3:
<statement/s>

In this example, CitectVBA tests the If condition, and jumps to the part of the script that begins with the label "Label1:" if the condition was true, or jumps to the part of the script that begins with the label "Label2:" if the condition was false. This could be anywhere in the same subroutine or function.

See Also

Control Structures