Raise Method
Generates a run-time error.
Syntax
object.Raise(number, source, description, helpfile, helpcontext)
Note:
helpfile, helpcontext are optional and not supported.
Arguments
- Object: Required. Always the Err object
- Number: Required. A Long integer subtype that identifies the nature of the error.
- Source: Optional. A string expression naming the object or application that originally generated the error. When setting this property for an Automation object, use the form project.class.
- Description: Optional. A string expression describing the error. If unspecified, the value in number is examined. If it can be mapped to a BSL run-time error code, a string provided by BSL is used as description. If there is no BSL error corresponding to number, a generic error message is used.
- Helpfile: Optional. The fully qualified path to the Help file in which help on this error can be found. If unspecified, BSL uses the fully qualified drive, path, and file name of the BSL Help file.
- Helpcontext: Optional. The context ID identifying a topic within helpfile that provides help for the error. If omitted, the BSL Help file context ID for the error corresponding to the number property is used, if it exists.
Remarks
All the arguments are optional except number. If you use Raise
,
however, without specifying some arguments, and the property settings of the
Err
object contain values that have not been cleared, those
values become the values for your error.
The following example illustrates use of the Raise
method.
Example 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
Example 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