This documentation is archived and is not being maintained.

ErrObject Class

The ErrObject module contains properties and procedures used to identify and handle run-time errors using the Err object.


Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public sealed class ErrObject

The ErrObject type exposes the following members.

Public propertyDescriptionReturns or sets a String expression containing a descriptive string associated with an error. Read/write.
Public propertyErlReturns an integer indicating the line number of the last executed statement. Read-only.
Public propertyHelpContextReturns or sets an Integer containing the context ID for a topic in a Help file. Read/write.
Public propertyHelpFileReturns or sets a String expression containing the fully qualified path to a Help file. Read/write.
Public propertyLastDllErrorReturns a system error code produced by a call to a dynamic-link library (DLL). Read-only.
Public propertyNumberReturns or sets a numeric value specifying an error. Read/write.
Public propertySourceReturns or sets a String expression specifying the name of the object or application that originally generated the error. Read/write.

Public methodClearClears all property settings of the Err object.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetExceptionReturns the exception representing the error that occurred.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRaiseGenerates a run-time error; can be used instead of the Error statement.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The ErrObject module supports the Err object. For more information, see Err.

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.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

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.