Variable Declarations

After adding and renaming the class module, the next step is to declare the variables that will hold the data you want to store in the object. Each item of data you want to store in an object should be assigned a variable. Class variables are called data members and are declared with the Private statement. Using this statement in a class module hides the data members and prevents other parts of the application from referencing them. Only the procedures

Introduction to Access 2003 VBA Programming within the class module in which the Private variables were defined can modify the value of these variables.

Because the name of a variable also serves as a property name, use meaningful names for your object's data members. It's traditional to preface the class variable names with m_ to indicate that they are data members of a class.

┬ęCustom Project 8-1 (Step 2): Declaring Class Members

1. Type the following declaration lines at the top of the CEmployee class module:

Option Explicit ' declarations

Private m_LastName As String Private m_FirstName As String Private m_Salary As Currency Private m_Id As String

Notice that the name of each data member variable begins with the prefix m_.

0 0

Post a comment