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
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.

See Also

Control Structures

Published June 2018