Creating a Class

The following sections of this chapter walk you through 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.

┬ęCustom Project 8-1 (Step 1): Creating a Class Module

This chapter's custom project is provided in the Acc2003_Chap08_Custom-Project.mdb file included in the book's downloadable files.

1. In the Visual Basic Editor window, choose Insert | Class Module.

2. In the Project Explorer window, highlight the Class module and use the Properties window to rename the class module CEmployee.

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 should 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