Muokkaa

Jaa


Conversion.ErrorToString Method

Definition

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

Overloads

ErrorToString()

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

ErrorToString(Int32)

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

ErrorToString()

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

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

public:
 static System::String ^ ErrorToString();
public static string ErrorToString ();
static member ErrorToString : unit -> string
Public Function ErrorToString () As String

Returns

The error message that corresponds to the most recent run-time error.

Exceptions

ErrorNumber is out of range.

Examples

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

Remarks

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.

See also

Applies to

ErrorToString(Int32)

Source:
Conversion.vb
Source:
Conversion.vb
Source:
Conversion.vb

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

public:
 static System::String ^ ErrorToString(int ErrorNumber);
public static string ErrorToString (int ErrorNumber);
static member ErrorToString : int -> string
Public Function ErrorToString (ErrorNumber As Integer) As String

Parameters

ErrorNumber
Int32

Optional. Any valid error number.

Returns

The error message that corresponds to a given error number.

Exceptions

ErrorNumber is out of range.

Examples

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

Remarks

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.

See also

Applies to