|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Resumes execution after an error-handling routine is finished.
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
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)