This documentation is archived and is not being maintained.

Conversion.ErrorToString Method

Returns the error message that corresponds to a given error number.

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

public static string ErrorToString()

Return Value

Type: System.String
The error message that corresponds to the most recent run-time error.

ExceptionCondition
ArgumentException

ErrorNumber is out of range.

The ErrorToString function examines the property settings of the Err object to identify the most recent run-time error. The return value of the ErrorToString function corresponds to the Description property of the Err object. If no run-time error has occurred, ErrorToString returns a zero-length string ("").

In Visual Basic version 6.0 and earlier, this functionality was provided by the Error function.

The following code uses the ErrorToString function to display error messages that correspond to the specified error numbers.


Dim ErrorNumber As Integer
For ErrorNumber = 61 To 64   ' Loop through values 61 - 64.
    MsgBox(ErrorToString(ErrorNumber))   ' Display error names in message box.
Next ErrorNumber


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