Generates a run-time error.
object.Raise number, source, description, helpfile, helpcontext
The object qualifier and named arguments of the Raise method are described in the following table.
Argument | Description |
---|---|
object | Required. Always the Err object. |
number | Required. Long integer that identifies the nature of the error. Visual Basic errors (both Visual Basic-defined and user-defined errors) are in the range 0–65535. When setting the Number property to your own error code in a class module, you add your error code number to the vbObjectError constant. For example, to generate the error number 1050, assign vbObjectError + 1050 to the Number property. |
source | Optional. String expression naming the object or application that generated the error. When setting this property for an object, use the form project.class. If source is not specified, the programmatic ID of the current Visual Basic project is used. |
description | Optional. String expression describing the error. If unspecified, the value in the Number property is examined. If it can be mapped to a Visual Basic run-time error code, the string that would be returned by the Error function is used as Description. If there is no Visual Basic error corresponding to the Number property, the "Application-defined or object-defined error" message is used. |
helpfile | Not supported. |
helpcontext | Not supported. |
All of the arguments are optional except number. If you use Raise without specifying some arguments, and the property settings of the Err object contain values that have not been cleared, those values serve as the values for your error.
Raise is used for generating run-time errors and can be used instead of the Error statement. Raise is useful for generating errors when writing class modules, because the Err object gives richer information than is possible if you generate errors with the Error statement.