ランタイム・エラーを生成します。
構文
object.Raise(number, source, description, helpfile, helpcontext)
注:
helpfile、helpcontextはオプションで、サポートされていません。
引数
備考
number以外のすべての引数はオプションです。ただし、引数を指定せずにRaiseを使用し、クリアされていない値がErrオブジェクトのプロパティ設定に含まれている場合、これらの値はエラーの値になります。
次の例では、Raiseメソッドの使用方法を示します。
例1:
Sub RaiseOverflowError() On Error Resume Next ' Enable error handling. Err.Raise 6 ' Raise an overflow error. Err.Clear ' Clear the error. End Sub 'Output: Number: 6, Description: Overflow
例2:
Sub RaiseCustomError() On Error Resume Next ' Enable error handling. Err.Raise 1000, "MyApp", "A custom error has occurred." Err.Clear ' Clear the error. End Sub 'Output: Number: 1000, Description: A custom error has occurred., Source: MyApp