CitectVBA Programming Reference > CitectVBA Function Reference > Conditional Statements > Goto

Goto

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.

Example

<statement/s>
If <condition> then
GoTo Label1
Else
GoTo Label2
End If

Label1:
<statement/s>
GoTo Label3

Label2:
<statement/s>
GoTo Label3

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.