エラーに関連する説明文字列を戻します。
構文
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