Goto Statement

Syntax

GoTo label

label

Use: Required

Subroutine name.

Description

Passes execution to a subroutine within a procedure.

Rules at a Glance

label must be a subprocedure defined within the same procedure as Goto.

Programming Tips and Gotchas

  • The only time a modern VB program should include a Goto statement is in an error handler, as in:

    On Error Goto My_Sub_Err
  • For more information on error handling, see Chapter 6.

See Also

GoSub...Return Statement, Chapter 6

Get VB & VBA in a Nutshell: The Language now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.