傳回與錯誤相關聯的描述性字串。
語法
object.Description
引數:
Object:必要。一律使用 Err 物件。
備註
Description 特性包含錯誤的簡短描述。如果未填入 Description,且數字的值對應至 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