Examples: On...GoSub statement

' The On...GoSub statement transfers control to Label3 and
' "Went to Label 3" is printed. Then control is returned to
' the statement following the On...GoSub statement, and
' "Successful return" is printed.
Sub Cleanup
   Dim x As Integer
   x% = 3
   On x% GoSub Label1, Label2, Label3
   Print "Successful return"   ' This prints
   Exit Sub
Label1:
   Print "Error"               ' This does not print
   Return
Label2:
   Print "Error"               ' This does not print
   Return
Label3:
   Print "Went to Label 3"     ' This prints
   Return
End Sub