Page 338 - Microsoft Office Excel 2003 Programming Inside Out
P. 338
Microsoft Office Excel 2003 Programming Inside Out
Practical Class Design
Now that you know what a class is and the mechanics of building one, it’s worth briefly cov
ering some practical tips for building classes.
A Simple Class
It’s quite reasonable to create a class that simply contains only properties and no methods.
(See Figure 14-2.)
Chapter 14
Figure 14-2. You can easily build a simple class in the Visual Basic Editor.
You can create this class by following these steps:
1 Select Insert, Class Module from the VBA main menu.
2 Select the new class in the Project Explorer, and change the Name property in the
Properties window to Plant.
3 Enter the following statements into the Edit Window:
Public CommonName As String
Public ScientificName As String
Public Description As String
Public RetailPrice As Currency
Public WholesaleCost As Currency
Public ProductNumber As Long
312
Part 4: Advanced VBA