Description 方法

返回与错误关联的描述性字符串。

语法

object.Description

参数:

Object必需。始终为 Err 对象。

注释

Description 属性包含有关错误的简短说明。如果未填写 Description,且 Number 的值对应于 BSL 运行时错误,则返回与错误关联的描述性字符串。

以下示例说明了 Description 方法的用法:

示例 1

Sub RaiseOverflowError()
    On Error Resume Next          ' Enable error handling.
    Err.Raise 6                   ' Raise an overflow error.
    Output = "Error # " & Err.Number & ": " & Err.Description
    Err.Clear                     ' Clear the error.
End Sub
'Output: Error # 6: Overflow

示例 2

Sub RaiseMultipleErrors()
    On Error Resume Next          ' Enable error handling.
    ' Raise a "Type Mismatch" error.
    Err.Raise 13
    Output1 = "Error # " & Err.Number & ": " & Err.Description

    Err.Clear                     ' Clear the error.
    ' Raise a "Division by Zero" error.
    Err.Raise 11
    Output2 = "Error # " & Err.Number & ": " & Err.Description

    Err.Clear                     ' Clear the error.
End Sub
'Output1: Error # 13: Type mismatch 
'Output2: Error # 11: Division by zero