Chapter 28: Object-Oriented Programming with VBA
983
The mix of properties (and their data types), methods (and the arguments accepted or returned by
the methods), and the events supported by a class are referred to as the class’s interface. A developer
working with an object created from a class module is typically unable to access the class’s interface,
and not the code within the class (unless, of course, the class’s creator and the developer working
with the class are the same person). Very often, class modules are bundled as Access libraries, or dis-
tributed as .mde or .accde files, and the interface is the only hint a developer has of the operations
supported by the class (unless printed or online documentation accompanies the class).
Managing a class’s interface
A class’s interface is revealed by the Object Browser (press F2 with the code editor window open).
Figure 28.5 shows the Object Browser open to the Product2 class, revealing the properties,
methods, and events supported by this class.
FIGURE 28.5
The Object Browser reveals a class’s interface.
At the bottom of the Object Browser, you can see that ProductName is defined as a public prop-
erty and is a string data type. This area is where you’d see that a property is read-only or write-
only. Also, all private elements are identified accordingly. Finally, notice how all the property
variables are sorted together because of the m_ prefix. (You can read about property variables in
the “Using Property Procedures” section, later in this chapter.)
Figure 28.6 illustrates one of the most valuable aspects of object-oriented programming. Notice
how the IntelliSense Auto List Members drop-down list shows you all the appropriate interface ele-
ments as soon as the object is identified and the dot is typed. This is a huge benefit to anyone
working with your class module.