Skip to content

RESUME NEXT


Error handling statement to resume execution after a jump to an error handler

Syntax

` Resume Next

`

Description

Resume Next is used in the traditional QB error handling mechanism within an error handler (called by On Error) to return execution to the line after the one that caused the error. Usually this is used to avoid executing the same line and causing the error again.

Resume Next resets the Err value to 0

Examples

start GeSHi

vb
'' Compile with -lang fblite or qb

#lang "fblite"

Dim As Single i, j

On Error Goto ErrHandler

i = 0
j = 5
j = 1 / i ' this line causes a divide-by-zero error; execution jumps to ErrHandler label

Print "ending..."

End ' end the program so that execution does not fall through to the error handler again

ErrHandler:

Resume Next ' execution jumps to 'Print "ending..."' line, but j is now in an undefined state

end GeSHi

Dialect Differences

  • RESUME NEXT is not supported in the -lang fb dialect. Statements can be used in its function form to return an error code

start GeSHi

vb
If Open( "text" For Input As #1 ) <> 0 Then
  Print "Unable to open file"
End If

end GeSHi

Differences from QB

  • Must compile with -ex or -exx option

See also

Back to DocToc

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft