![Page 1: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/1.jpg)
Introduction to Class Modules
Please use speaker notes for additional information!
![Page 2: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/2.jpg)
PrItemClass.vbpPrItemClass.vbp
![Page 3: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/3.jpg)
![Page 4: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/4.jpg)
PrItemClass.vbpPrItemClass.vbp
![Page 5: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/5.jpg)
PrItemClass.vbpPrItemClass.vbp
![Page 6: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/6.jpg)
Option ExplicitPrivate modvarOnHand As IntegerPrivate modvarOnOrder As IntegerPrivate modvarCost As Integer'The value of the property OnHand is kept in modvarOnHand'These variables at the module level are the properties of the new class'These three properties are declared as private and can only be accessed by the procedures'that are within the class module'Since I want access from outside the class, I develop property procedures
'To expose the properties to the outside world, I need get and let proceduresPublic Property Get OnHand() As Integer'Retrieve the current onhand value OnHand = modvarOnHandEnd Property
Public Property Let OnHand(ByVal intOnHand As Integer)'Assign the onhand property value modvarOnHand = intOnHandEnd Property
Public Property Get OnOrder() As Integer OnOrder = modvarOnOrderEnd Property
Public Property Let OnOrder(ByVal intOnOrder As Integer) modvarOnOrder = intOnOrderEnd Property
Public Property Get Cost() As Integer Cost = modvarCostEnd Property
Public Property Let Cost(ByVal intCost As Integer) modvarCost = intCostEnd Property
In the Get, I assigned the private variable to the property name defined when I created the property procedure.
In the Let, I assigned the value received by the Let to the private variable.
PrItemClass.vbpPrItemClass.vbp
![Page 7: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/7.jpg)
![Page 8: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/8.jpg)
PrItemClass.vbpPrItemClass.vbp
![Page 9: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/9.jpg)
PrItemClass.vbpPrItemClass.vbp
![Page 10: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/10.jpg)
PrItemClass.vbpPrItemClass.vbp
500 + 25 = 525
250 - 25 = 225
![Page 11: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/11.jpg)
PrItemClassSet.vbpPrItemClassSet.vbp
![Page 12: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/12.jpg)
The object mItem is declared and then instantiated with the Set statement.
![Page 13: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/13.jpg)
PrItemClassSet.vbpPrItemClassSet.vbp
![Page 14: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/14.jpg)
PrItemClassEvent.vbpPrItemClassEvent.vbp
There are two events that will be raised or triggered when appropriate.
If the modvarOnHand drops below 50 it will raise the event NeedToOrder.
If the mdovarOnOrder = 0 it will raise the event NothingOnOrder.
![Page 15: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/15.jpg)
PrItemClassEvent.vbpPrItemClassEvent.vbp
More code showing when events are raised.
This code also shows a new method - SellProdcut which will decrease the on hand for the product.
![Page 16: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/16.jpg)
PrItemClassEvent.vbpPrItemClassEvent.vbpThe object is declared here and instantiated with the Set statement in the load.
![Page 17: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/17.jpg)
PrItemClassEvent.vbpPrItemClassEvent.vbp
This is the other event that is raised or triggered when onorder becomes 0.
![Page 18: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/18.jpg)
PrItemClassEvent.vbpPrItemClassEvent.vbp
![Page 19: Introduction to Class Modules Please use speaker notes for additional information!](https://reader035.vdocuments.net/reader035/viewer/2022081512/56649dd05503460f94ac626f/html5/thumbnails/19.jpg)
PrItemClassEvent.vbpPrItemClassEvent.vbp