Goto
Previous Top Next

Changes the program position.
Goto causes the program to move to a predefined label.

Labels:

Label syntax is a word starting with a letter and ending with a colon.

Example:
Sub Button1_Click
            ...
StartingPlace:
            ...
            Goto StartingPlace
End Sub

Result: When the program reaches the Goto keyword it will move to the first line after StartingPlace.

Although you can use Goto to jump between different subs it may cause unpredictable errors because the local variables will still be the variables of the previous sub.
Goto is best used to jump inside a sub.

The optimized compiler doesn't allow jumps between different subs, and the target label must be in a scope equal or wider to the calling Goto.