In general, a line number or label reference within a subprogram must refer to a line also within the subprogram. The on error goto statement is an exception. Even within a subprogram, the line number or label reference of this statement must refer to a line outside any subprogram. Upon completion, the error recovery routine is responsible for seeing that execution resumes within the subprogram which caused the error lest the control structure of the program be corrupted.
A moduleís error handling routines are private to the module. An on error goto statement executed within one module does not effect code in other modules. The possibility (and opportunity) exists to have an error handling routine in each of several modules concurrently identified and prepared to execute in case of error. Transfer of control between modules due to error handling is impossible.
data 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7 on error goto 6 5 read a print a goto 5 6 restore resume 7 endtraps the common error of attempting to read beyond the end of data.
from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber