13.1. A Touch of Class

Classes have been likened to rubber stamps, cookie-cutters, and a raft of other everyday items in an attempt to make the concept more easily understandable. Because you are reading a book on software development, it seems fairly safe to assume that you understand the concept of a template, such as a Microsoft Word template. That analogy succinctly describes the role of class modules and the distinction between them and class objects.

Just as a class module is equivalent to a Word template, a class object is equivalent to a Word document that is based on that template. Of course, with VBA class modules, you don't define styles or boilerplate text, but you do define a set of properties that includes their data types and read-write attributes. You also define the methods of a class, the data types they return (if any), and the events the class exposes to the calling procedure. It is these properties and methods that constitute the object's interface to the programming environment.

Each unique class object will be exactly the same as the class module it was based on, except of course, for the data it contains. In fact, the class module never gets instantiated and never contains any data because you don't actually work on it. You can, however, create as many instances of it as you like, in the form of class objects, each identified by a different name. To make a change to all the class objects, you need change only the class module. Probably the easiest way to ...

Get Access™ 2007 VBA Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.