Class Module Errors
Class modules are not immune to runtime errors, but the way you handle them is a bit different from standard modules. Also, you can define custom errors that represent other object occurrences that your application needs to react to.
In general, you do not want a class to handle its own errors directly. Instead, a class should report errors to the program that is using it, so that the program can handle the errors in a manner appropriate to the situation. This includes VBA's built-in errors, as well as error situations that are specific to your class, such as an inappropriate value being passed as a method argument.
To define custom errors, it is necessary to associate a number with each error. Clearly, you cannot use a number ...
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