Skip to Content
VB & VBA in a Nutshell: The Language
book

VB & VBA in a Nutshell: The Language

by Paul Lomax
October 1998
Intermediate to advanced
656 pages
16h 10m
English
O'Reilly Media, Inc.
Content preview from VB & VBA in a Nutshell: The Language
Return Statement

Syntax

GoSub label
...
label

Return

label

Use: Required

A subroutine label within a procedure.

Description

Branches back to a calling GoSub statement after executing a subroutine within a procedure.

Rules at a Glance

  • A subroutine can include an number of Return statements.

  • Return branches back to the statement immediately following the last executed GoSub statement in the current subroutine.

  • A GoSub statement and the subroutine it calls must reside within the same procedure.

Programming Tips and Gotchas

The Return statement is only included in this book for completeness, should you have to maintain legacy code; otherwise, you shouldn't be writing new code using the GoSub...Return statements, since it tends to create "spaghetti" code that is very difficult to read and to maintain. Code should be rewritten using separate procedures.

See Also

GoSub Statement
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Absolute Beginner's Guide to VBA

Absolute Beginner's Guide to VBA

Paul McFedries
Visual Basic 2015 Unleashed

Visual Basic 2015 Unleashed

Alessandro Del Sole

Publisher Resources

ISBN: 1565923588Catalog PageErrata