Creating the Property Get Procedures

The CEmployee class object has four properties that need to be exposed to VBA procedures that reside in other modules in the current VBA project. When working with the CEmployee object, you would certainly like to get information about the employee ID, first and last name, and current salary. 1. Type the following Property Get procedures in the CEmployee class module, just below the declaration section:

Property Get Id( ) As String

Id = m_Id End Property

Property Get LastName( ) As String

LastName = m_LastName End Property

Property Get FirstName( ) As String

FirstName = m_FirstName End Property

Property Get Salary( ) As Currency

Salary = m_Salary End Property

Each type of the needed employee information requires a separate Property Get procedure. Each one of the above Property Get procedures returns the current value of the property. Notice how a Property Get procedure is similar to a function procedure. Like function procedures, the Property Get procedures contain an assignment statement. As you recall from Chapter 4, to return a value from a function procedure, you must assign it to the function's name.

0 0

Post a comment