Chapter 3. Programming Class Modules
Class modules can be a powerful tool in your programming toolbox and writing them is one of our favorite programming tasks in VBA. If you have worked with classes in object-oriented languages such as C++ or C#, you might be disappointed to learn that VBA is not a true object-oriented programming language because both VB and VBA lack implementation inheritance. However, class modules in VBA provide many other strengths that can save you time when programming Access or VBA applications. With that in mind, you learn the following about class modules by the end of this chapter:
The components that make up a class module including properties, methods, enumerations, and events
How to reuse code that you write in class modules
How to subclass other classes to add your own functionality or to reduce the amount of code to write
How to write interfaces in VBA
How to write powerful and reusable collection classes
How to create custom events
Design considerations for VBA class modules
Overview of Class Modules
Object-oriented programming (OOP) has been around for a while, and the mainstay of OOP is the class. A class defines the blueprint for an object where an object is merely an instance of a class. Many classes that you design can have multiple instances, or objects, but there might be times where you want to allow only one instance of a class. You can find out more about these types of classes later in this chapter in the section "Design Considerations."
The Class ...