Method: Raise for Err
- Updated2024-09-12
- 1 minute(s) read
Methods > Method: Raise for Err
Method: Raise for Err
Generates a runtime error.
Object.Raise(number, Source, Description, helpfile, HelpContext)
Object | Err Object with this method |
number | Variant Specifies the error number. VBScript errors range from 0 to 65535. |
Source | Variant Specifies the name of the application that triggered an error. If you do not specify a value, the Raise method uses the "Microsoft VBScript runtime error" value. |
Description | Variant Returns an error description. If you do not specify the value and if number corresponds to a VBScript runtime error, the Raise method uses the error description of this runtime error. Otherwise, the method uses a general error description. |
helpfile | Variant Specifies the path to a help file. The help file must be an HLP file. |
HelpContext | Variant Specifies the ContextID of a help topic. |
The following example generates an error and displays the error number and the error description:
Dim sOutput On Error Resume Next Call Err.Raise(6) 'Raise an overflow error If Err.Number <> 0 Then sOutput = "Error Number: " & Err.number & VBCrLf & _ "Description: " & Err.Description Call MsgBox(sOutput, , "Error: " & Err.Description) End If On Error Goto 0 Call Err.Clear()