Property procedures are routines that can represent a property-like value. A normal read-write property procedure contains a function for returning the property’s value and a subroutine for assigning it.
The following code shows property procedures that implement a Value property. The Property Get procedure is a function that returns the value in the private variable m_Value. The Property Set subroutine saves a new value in the m_Value variable.
Private m_Value As Single Property Value() As Single Get Return m_Value End Get Set(ByVal Value As Single) m_Value = Value End Set End Property
Although the property is implemented as a pair of property procedures, the program could treat the value as a simple property. For example, suppose that the OrderItem class contains the previous code. Then the following code sets the Value property for the OrderItem object named paper_item:
paper_item.Value = 19.95
You can add property procedures to any type of object module. For example, you can use property procedures to implement a property for a form or for a class of your own.
It’s less obvious that you can also use property procedures in a code module. The property procedures look like an ordinary variable to the routines that use them. If you place the previous example in a code module, the program could act as if there were a variable named Value defined in the module.
For more information on property procedures, see the section “Property Procedures” in Chapter 4.