By using the CVErr() and IsError() functions and the Application.AccessError method, you can create your own functions that can return an error value if an error situation occurs in the function. Here's a short description of each function and method that can be used:
The CVErr() function converts a value to an Error data type, assigning it to a Variant variable.
The IsError() function checks to see whether a Variant is an Error data type.
The Application.AccessError method provides an error description without the error itself.
An example of using these commands is when you divide two numbers—either the function receives a text value instead of the number needed, or a zero is sent. Listing 7.10 shows the cmdTestCVErr_Click ...
No credit card required