Explanation
GOSUB...RETURN Statement
Branches to and returns from a subroutine.Worth knowing
Useful and cross-version information about the programming environments of QBasic, QuickBasic and Visual Basic for DOS.
Useful and cross-version information about the programming environments of QBasic, QuickBasic and Visual Basic for DOS.
GOSUB line1 . . . RETURN [line2] |
line1 | The label or line number of the first line of the subroutine. |
line2 | The label or line number where the subroutine returns. |
If you don't supply a label or line number for RETURN, the program continues execution at the statement following the GOSUB (for subroutine calls) or where an event occurred (for event handling). See the ON keyword for information about event-handling statements. | |
SUB and CALL statements provide a better alternative to GOSUB subroutines. |
FOR i% = 1 TO 20
GOSUB Square
NEXT i%
END
Square:
PRINT i%, i% * i%
RETURN
See also: | CALL | ON Keyword | ON GOSUB, ON GOTO | SUB |