The ErrObject module contains properties and procedures used to identify and handle run-time errors using the Err object.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
Returns or sets a String expression containing a descriptive string associated with an error. Read/write.
Returns an integer indicating the line number of the last executed statement. Read-only.
Returns or sets an Integer containing the context ID for a topic in a Help file. Read/write.
Returns or sets a String expression containing the fully qualified path to a Help file. Read/write.
Returns a system error code produced by a call to a dynamic-link library (DLL). Read-only.
Returns or sets a numeric value specifying an error. Read/write.
Returns or sets a String expression specifying the name of the object or application that originally generated the error. Read/write.
Clears all property settings of the Err object.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Returns the exception representing the error that occurred.
Serves as the default hash function. (Inherited from Object.)
|Raise(Int32, Object, Object, Object, Object)|
Generates a run-time error; can be used instead of the Error statement.
Returns a string that represents the current object.(Inherited from Object.)
This example uses the properties of the Err object in constructing an error-message dialog box. Notice what happens when you use the Clear method first: When you then generate a Visual Basic error with the Raise method, Visual Basic's default values become the properties of the Err object.
Dim Msg As String ' If an error occurs, construct an error message. On Error Resume Next ' Defer error handling. Err.Clear Err.Raise(6) ' Generate an "Overflow" error. ' Check for error, then show message. If Err.Number <> 0 Then Msg = "Error # " & Str(Err.Number) & " was generated by " _ & Err.Source & ControlChars.CrLf & Err.Description MsgBox(Msg, MsgBoxStyle.Information, "Error") End If
Available since 1.1
Available since 2.0
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.