Error, Error$ Functions |
Named Arguments
No
Syntax
Error[(errornumber)]
errornumber
Use: Optional
Data Type: Long
Any valid error code.
Return Value
Error returns a variant of subtype string; Error$ returns a String. Both return values are standard descriptions for the particular error code.
Description
Returns either the error description corresponding to the given error number or the description for the last error.
Rules at a Glance
If errornumber isn't passed to the function, Error returns the description for the last error to have occurred. If no errors have occurred, a zero-length string ("") is returned.
If errornumber isn't recognized as a VB error, the function returns the description "Application-defined or object-defined error."
If errornumber is outside the range of a valid error code, an overflow error is generated.
Example
x = Error(100)
Programming Tips and Gotchas
The Error and Error$ functions are included for only backward compatibility. Instead, you should use the Description property of the Err object in all new code. The Error$ function, however, is useful for obtaining an error description for any error code "after the event," when perhaps the Err object has been reinitialized.
See Also
- Err.Description Property
Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.