how a GoTo statement works: : GoTo « Language Basics « VBA / Excel / Access / Word

how a GoTo statement works:

Sub GoToDemo()
    userName = InputBox("Enter Your Name: ")
    If userName <> "123" Then GoTo WrongName
    MsgBox ("Welcome Bill...")
'   ...[More code here] ...
    Exit Sub
    MsgBox "Sorry."
End Sub


Related examples in the same category

1.A line number is simply a number placed at the beginning of a line to identify it. For example, consider this demonstration of GoTo:
2.A GoTo statement with a condition
3.Use GoTo to do a loop