Solved

Default values in class

Posted on 2002-03-26
5
157 Views
Last Modified: 2010-05-02
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
Comment
Question by:dcaparaso
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
COAtheGREAT earned 50 total points
ID: 6896729
Use Class_Initialize event to set default values

Private Sub Class_Initialize()

  myProp1=...

End Sub
0
 
LVL 2

Expert Comment

by:ronenr
ID: 6896730
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
 
LVL 2

Expert Comment

by:ronenr
ID: 6896741
Opps a fix

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

Author Comment

by:dcaparaso
ID: 6896928
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
 
LVL 1

Expert Comment

by:COAtheGREAT
ID: 6896931
correct :)
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question