QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The ERR function returns the last QBasic error code number.

Syntax

errorNum% = ERR

Description

Example(s)

Simulating an error to test a program error handler that looks for a “Subscript out of range” error.


ON ERROR GOTO handler

IF x = 0 THEN ERROR 111  'simulate an error code that does not exist
x = x + 1
IF x THEN ERROR 9        'simulate array boundary being exceeded

END

handler:
PRINT ERR, _ERRORLINE
BEEP
IF ERR = 9 THEN
  PRINT "The program has encountered an error and needs to close! Press a key!"
  K$ = INPUT$(1)
  SYSTEM
END IF
RESUME NEXT               'RESUME can only be used in error handlers 

See Also