Why Create Classes?

Some readers may be wondering why they should go to the trouble of creating custom classes. It's true that there is nothing a class can do that could not also be done in “regular” VBA code without a class. The major advantage of classes comes in the areas of programming ease and reusability. Once you have created the class, you can use it in your program—and reuse it in other programs—much more easily than if you had implemented the same functionality outside of a class. This is called encapsulation, meaning that all the functionality related to a specific program task is contained within the class. Letting others use your code is a lot easier with classes too.

Do these advantages outweigh the extra work involved in creating ...

Get Office® XP Development with VBA 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.