Creating a Class

The remaining sections of this chapter demonstrate the process of creating and working with a custom object called CEmployee. This object will represent an employee. The CEmployee object will have properties such as Id, FirstName, LastName, and Salary. It will also have a method for modification of the current salary.

1. Highlight ObjColClass (Chap11.xls) in the Project Explorer window and choose Insert | Class Module.

2. Highlight Class module in the Project Explorer window and use the Properties window to rename the class module CEmployee.

Tip 11-2: Naming a Class Module

Every time you create a new class module, give it a meaningful name. Set the name of the class module to the name you want to use in your VBA procedures using the class. The name you choose for your class should be easily understood and identify the "thing" the object class represents. As a rule, the object class name is prefaced with an uppercase "C".

0 0

Post a comment