Terminology
Classes are like cookie cutters; you don't eat the cookie cutter, but you use it to make cookies.
The cookies are the objects. When you make a cookie using a cookie cutter, you instantiate an object of the cookie class.
Create a New Class
Define the Class Properties (the members in the class)
' Use the prefix "m" (for module) and the data type for each property
Private mcurPrice As Currency
Private mintQuantity As Integer
Private mstrDescription As String
Add Property Procedures (the let and get members of the class)
Public Property Get
Quantity() As Integer
' used to return Quantity to the caller
Quantity = mintQuantity
End Property
Public Property Let
Quantity(ByVal intQuantity As Integer)
' used to set Quantity with a caller-supplied parameter
mintQuantity = intQuantity
End Property
Public Property Get Price() As Currency
Price = mcurPrice
End Property
Public Property Let Price(ByVal curPrice As Currency)
mcurPrice = curPrice
End Property
Public Property Get Description() As String
Description = mstrDescription
End Property
Public Property Let Description(ByVal strDescription As String)
mstrDescription = strDescription
End Property
Code a Method
Public Function
ExtendedPrice() As Currency
' Calculate the value of the product
ExtendedPrice = mcurPrice * mintQuantity
End Function
Creating a New Object Using a Class

Private mproduct As
CProduct
Run It !
Download: the form, the class, the project
Next: Collections
Last
update:
Wednesday February 18, 2009
Questions: email
Prof Domanski