產生執行時期錯誤。
語法
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