How do you invoke the Let and Get class Functions

S

SeekingMoSkills

I have create classes with the Let and Get functions and now I would like to
use these functions to store and retrieve data in the class which will then
be put into a collection.

Here is the class functions:
Private pBusPart As Double
Private pStartTime As Date
Private pIndex As Integer

''''''''''''''''''''''
' BusPart property
''''''''''''''''''''''
Public Property Get BusPart() As Double
BusPart = pBusPart
End Property
Public Property Let BusPart(Value As Double)
pBusPart = Value
End Property

''''''''''''''''''''''
' StartTime property
''''''''''''''''''''''
Public Property Get StartTime() As Date
StartTime = pStartTime
End Property
Public Property Let StartTime(Value As Date)
StartTime = Value
End Property

''''''''''''''''''''''
' Index property
''''''''''''''''''''''
Public Property Get Index() As Integer
Index = pIndex
End Property
Public Property Let Index(Value As Integer)
pIndex = Index
End Property
 
B

Bob Phillips

Something like

Set myClass = New clsBus
With myClass

.BusPart =23.5
.StartIme = #25/10/2009#
.Index = 7

MsgBox "Buspart: " & .BusPart & ", Startime: " & .StartTime &
".INdex: " & .Index
End With

HTH

Bob
 
S

SeekingMoSkills

Thanks for the post Bob. So if I understand this correctly the Get and Let
functions are never called by name but they need to be there to load or
retrieve the values. Is that a correct statement?
 
B

Bob Phillips

They are not called by name as they are properties not methods (they are not
functions), so you read/write from/to them.

Properties are attributes of an object (class), and the Let/Get construct is
the interface for those properties between the code that creates that object
and the code in the class that maintains that object. Methods are the way
that the object does things, or has things done to it (such as calculating a
runtime).

HTH

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top