Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Class Modules Please use speaker notes for additional information!

Similar presentations


Presentation on theme: "Introduction to Class Modules Please use speaker notes for additional information!"— Presentation transcript:

1 Introduction to Class Modules Please use speaker notes for additional information!

2 PrItemClass.vbp

3

4

5

6 Option Explicit Private modvarOnHand As Integer Private modvarOnOrder As Integer Private 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 procedures Public Property Get OnHand() As Integer 'Retrieve the current onhand value OnHand = modvarOnHand End Property Public Property Let OnHand(ByVal intOnHand As Integer) 'Assign the onhand property value modvarOnHand = intOnHand End Property Public Property Get OnOrder() As Integer OnOrder = modvarOnOrder End Property Public Property Let OnOrder(ByVal intOnOrder As Integer) modvarOnOrder = intOnOrder End Property Public Property Get Cost() As Integer Cost = modvarCost End Property Public Property Let Cost(ByVal intCost As Integer) modvarCost = intCost End 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.vbp

7

8

9

10 500 + 25 = 525 250 - 25 = 225

11 PrItemClassSet.vbp

12 The object mItem is declared and then instantiated with the Set statement.

13 PrItemClassSet.vbp

14 PrItemClassEvent.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.

15 PrItemClassEvent.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.

16 PrItemClassEvent.vbp The object is declared here and instantiated with the Set statement in the load.

17 PrItemClassEvent.vbp This is the other event that is raised or triggered when onorder becomes 0.

18 PrItemClassEvent.vbp

19


Download ppt "Introduction to Class Modules Please use speaker notes for additional information!"

Similar presentations


Ads by Google