生成运行时错误。
语法
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