Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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