Resume Statement
Resumes execution after an error-handling routine is finished.
We suggest that you use structured exception handling in your code whenever possible, rather than using unstructured exception handling and the On Error and Resume statements. For more information, see Try...Catch...Finally Statement (Visual Basic).
Resume [ Next | line ]
Note
|
|---|
|
We recommend that you use structured exception handling in your code whenever possible, rather than using unstructured exception handling and the On Error and Resume statements. For more information, see Try...Catch...Finally Statement (Visual Basic). |
If you use a Resume statement anywhere other than in an error-handling routine, an error occurs.
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 use of 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
Namespace: Microsoft.VisualBasic
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)
Note