From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Language Keyword

Jumps to a statement label.


GoTo label

Part Description
label Label to which to jump.


The GoTo statement is included for historical reasons only. Historically, GoTo was used extensively in unstructured code to manage flow-of-control. At that time, a program consisted of a single master code segment, with flow-of-control managed by numerous GoTo statements that jumped execution around from one section of code to another. In time, such programs proved very hard to maintain because the underlying logic of the program was difficult to follow-especially after the original programmer left the project. The inability to maintain unstructured programs led to the development of event-driven, object-oriented programming environments such as Xojo.

The label appears on a separate line and it is followed by an ":" character.

Sample Code

The following example displays a warning message if Checkbox1 is checked.

If Checkbox1.Value Then
Goto myCode
End If
// Return used to keep from executing the labeled statement anyway
myCode: // label to jump to
MessageBox("Unstructured programming is bad.")

In place of all this, it is recommended that you use:

If Not CheckBox1.Value Then Return

See Also

Exit, Return statements.