Microsoft Office Tutorials and References
In Depth Information
Building a Class
The class module contains all of the properties, methods, and events associated with the
class’s interface, along with any local variables, functions, and subroutines used by the class.
Creating a Class Module
You can add a class module to your VBA program by choosing Insert, Class Module from
Visual Basic’s main menu. The initial name of the class is formed by appending a unique
number to the word Class . Thus, the first class you create will be Class1 , and the second will
be Class2 .
Because a name like Class1 isn’t very descriptive, you should always give the class a more
meaningful name. To change the name of a class, select the class in the Project Explorer, and
then go to the Properties window and change the Name property associated with this class.
(See Figure 14-1.)
Figure 14-1. Use the Properties Window to change the Name property associated with
the class.
Defining Simple Properties
There are two different types of properties: public class-level variables and property routines.
Class-level variables must be defined before any subroutines, functions, or property routines
are defined. In practical terms, this means that all of your class-level variables should be
located at the start of the class module.
Search JabSto ::




Custom Search