Raise Method
Generate runtime error
object.Raise(number, source, description, helpfile, helpcontext)
Parameters
Object
Should beErrObject.
Number
LongThe integer subtype, indicating the nature of the error. The VBScript error range is between 0 and 65535.
Source
Name the string expression of the object or application that originally generated an error. Use a form when setting this attribute for an Automation ObjectProject. class. If no value is specified, the program design ID of the current VBScript project is used.
Description
The string expression that describes the error. If not specified, checkNumber. If you can map it to an error code During VBScript running, use the string provided by VBScriptDescription. If notNumberIf the corresponding VBScript error occurs, the common error message is used.
Helpfile
The complete and valid path of the Help file. You can find the Help information for this error in the Help file. If not specified, VBScript uses the complete and valid drive, path, and file name of the VBScript Help file.
Helpcontext
Context ID, IDHelpfile. If this parameter is omittedNumberThe incorrect VBScript Help file context ID corresponding to the attribute (if any ).
Description
BesidesNumberAll other parameters are optional. If you useRaiseWithout specifying some parameters, andErrIf the property settings of an object contain uncleared values, these values become incorrect values.
Set the error code in Automation objectNumberConstantVbObjectErrorAdd the error code number. For example, to generate error 1050, you canNumberAttribute Value:VbObjectError+ 1050.
The following example illustrates how to useRaiseMethod:
On Error Resume NextErr.Raise 6 'Overflow error.MsgBox ("Error # " & CStr(Err.Number) & " " & Err.Description)Err.Clear 'Clear the error.