ErrorToString Method ()
Collapse the table of content
Expand the table of content

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 ()
public static String ErrorToString ()
public static function ErrorToString () : String
Not applicable.

Return Value

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

For more detailed information, see the Visual Basic topic ErrorToString Function.

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 ErrorNumber is a valid error number but is not defined, ErrorToString returns the string "Application-defined or object-defined error." If ErrorNumber is not valid, an error occurs. If ErrorNumber is omitted, the message corresponding to the most recent run-time error is returned. If no run-time error has occurred or ErrorNumber is 0, 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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2016 Microsoft