• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

Default values in class

Probably a real easy question...

If I want a property of my class to have a default value what is the proper way to implement?  Is there a default setting of a let statement?  is it best to check for ismissing in any functions that use the property?

0
dcaparaso
Asked:
dcaparaso
  • 2
  • 2
1 Solution
 
COAtheGREATCommented:
Use Class_Initialize event to set default values

Private Sub Class_Initialize()

  myProp1=...

End Sub
0
 
ronenrCommented:
You can have a member variable where you store the default value, this value can be set in the initialize procedure of your class.

eg

private mValue as string

public property let Value(byval val as string )
   mValue
end property

public property get Value() as string
 Value = mValue
end property


Private Sub Class_Initialize()
   mValue="test string"
end sub
0
 
ronenrCommented:
Opps a fix

public property let Value(byval val as string )
  mValue=val
end property
0
 
dcaparasoAuthor Commented:
and then if a client sets a property that was first set during intialize event the variable is replaced with the client's value - correct?

0
 
COAtheGREATCommented:
correct :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now