<< Click to Display Table of Contents >> Goto (statement) |
Goto Label
.
.
.
Label:
Statements
Unconditional jump to the target Label.
The jump target Label must reside inside the same subroutine or function from which the command Goto is called.
Note: This statement is provided only for compatibility reasons. Use of Goto statements makes program code unnecessarily complicated. It is recommended to use structured control statements (Do ... Loop, For ... Next, If ... Then ... Else, Select Case) instead.
See also: Gosub Return, Sub, section Flow control
Example:
Sub Main
Dim x
For x = 1 to 5
Print x
If x > 3 Then
Goto Label1
End If
Next x
Label1:
Print "That's enough!"
End Sub