Resume (statement)

Syntax

Resume {[0] | Next | label}

Description

Ends an error handler and continues execution.

Comments

The form Resume 0 (or simply Resume by itself) causes execution to continue with the statement that caused the error.

The form Resume Next causes execution to continue with the statement following the statement that caused the error.

 

The form Resume label causes execution to continue at the specified label.

The Resume statement resets the error state. This means that, after executing this statement, new errors can be generated and trapped as normal.

Example

This example accepts two integers from the user and attempts to multiply the numbers together. If either number is larger than an integer, the program processes an error routine and then continues program execution at a specific section using 'Resume <label>'. Another error trap is then set using 'Resume Next'. The new error trap will clear any previous error branching and also 'tell' the program to continue execution of the program even if an error is encountered.

Sub Main()
  Dim a%,b%,x%

Again:
  On Error Goto Overflow
  a% = InputBox("Enter 1st integer to multiply","Enter Number") 
  b% = InputBox("Enter 2nd integer to multiply","Enter Number")
    
  On Error Resume Next  'Continue program execution at next line
  x% = a% * b%     'if an error (integer overflow) occurs.

  If err = 0 Then
    MsgBox a% & " * " & b% & " = " & x%
  Else
    Msgbox a% & " * " & b% & " cause an integer overflow!"
  End If

  Exit Sub

Overflow:       'Error handler.
  MsgBox "You've entered a non-integer value, try again!"
  Resume Again
End Sub

See Also

Error Handling (topic); On Error (statement).

More information

R