Name
Err.Number Property
Data Type
Long
Description
A read/write property containing a type Long value that represents the error code for the last error generated.
Rules at a Glance
When a runtime error is generated within the program, the error code is automatically assigned to Err.Number.
The Number property is updated with an application-defined error whose code is passed as an argument to the Err.Raise method.
When using the Err.Raise method in normal code, your user-defined error codes can’t be greater than 65536 or less than 0. (See the final note in the “Programming Tips and Gotchas” section of the entry for the Err.Raise method.)
VBScript uses error numbers in the range of 1-1058 as well as 32766-32767 and 32811 for its own trappable errors. In implementing a series of application-defined errors, your error handlers should either translate application errors into VBScript trappable errors or, preferably, assign a unique range to application-defined errors.
If your code instantiates an ActiveX server, its error codes should be increased by the value of the VBScript intrinsic constant
vbObjectError. When control returns to the local application after an error has been raised by the OLE server, the application can determine that the error originated in the OLE server and extract the error number with a line of code like the following:Dim lError If ((Err.Number And &HFF00) And vbObjectError) Then lError = Err.Number XOr vbObjectError
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access