default value for class module

G

Guest

Dear all,

I just started to learn to use class module. I am trying to figure out how
to set up a default value for some of the parameteres. Can you guys give me
a simple example? Thanks a million!

chun
 
K

Ken Snell \(MVP\)

Easiest way is to use the Class_Initialize procedure to set default values
for the desired variables/properties within the class.
 
G

Guest

You mean I should assign default values first (initializing) in a regular sub
before using it? Thanks.

chun
 
D

Douglas J. Steele

I believe what Ken's suggesting is that you provide the default values in
the class's Initialize Event.

Private lngProperty1 As Long
Private strProperty2 As String

Private Sub Class_Initialize()

lngProperty1 = 15
strProperty2 = Sell

End Sub

Public Property Get Property1 As Long

Property1 = lngProperty1

End Property

Public Property Get Property2 As String

Property2 = strProperty2

End Property
 
K

Ken Snell \(MVP\)

Douglas J. Steele said:
I believe what Ken's suggesting is that you provide the default values in
the class's Initialize Event.


Yes, that is what I am suggesting < g >.
 

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