Resumes execution after an error-handling routine is finished.
Resume [ Next | line ]
If you use a Resume statement anywhere except in an error-handling routine, an error will occur.
The Resume statement cannot be used in any procedure that contains a Try?Catch?Finally statement.
This example uses the Resume statement to end error handling in a procedure, and then resume execution with the statement that caused the error. Error number 55 is generated to illustrate using the Resume statement.
Sub ResumeStatementDemo()
On Error GoTo ErrorHandler ' Enable error-handling routine.
Dim x As Integer = 32
Dim y As Integer = 0
Dim z As Integer
z = x / y ' Creates a divide by zero error
Exit Sub ' Exit Sub to avoid error handler.
ErrorHandler: ' Error-handling routine.
Select Case Err.Number ' Evaluate error number.
Case 6 ' "Divide by zero" error.
y = 1 ' Sets the value of y to 1 and tries the calculation again.
Case Else
' Handle other situations here....
End Select
Resume
' Resume execution at same line
' that caused the error.
End Sub
Try...Catch...Finally Statements | Error Statement | On Error Statement