Returns a specific type of error (Variant).

errornumberThe error number.

* This function can be used to create user defined errors in your procedures.
* This function can be used to return an error from a user defined function.
* If "errornumber" < 0, then a run-time error is displayed.
* If "errornumber" is not a number, then a run-time error is displayed.
* The implicit conversion of an error is not allowed.
* This function always returns a variant whose value has been converted to an Error Subtype.
* There does not actually exist an error data type although it is possible to have a Variant data type whose subtype is Error.
* You can use the ERROR - Function to return the error message corresponding to a given error number.
* You can use the ERROR - Statement to generate an error.
* You can use the ISERROR function to return True or False depending if an expression is an error.
* For the Microsoft documentation refer to

Debug.Print CVErr(6)           ' Error 6  
Debug.Print CVErr(11) ' Error 11
Debug.Print CVErr(55) ' Error 55
Debug.Print CInt(CVErr(2000)) ' 2000
Debug.Print CVErr(-100) ' generates an Invalid Procedure Call or Argument run-time error
Debug.Print CVErr("some text") ' generates a Type Mismatch run time error

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top