Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

class intialization parameter 1

Status
Not open for further replies.

hwkranger

MIS
Nov 6, 2002
717
US
is there a way to pass a parameter to class at initialization?

eg...
Code:
Private Sub Class_Initialize(objClassData As clsBuildCode)
    Set objBuildForm.adtClassData = objClassData
End Sub
I can't seem to pass data at intialization, how does VBA do this?

Randall Vollen
Merrill Lynch
 
VBA (and VB6) classes don't have constructors. You therefore have to initialize the object, and then pass in the data, either through a method or a property.


 
They do have a Class_Initialize method that you can use to set default values. That method (if it exists) runs when a new instance of the class is instantiated.

Its not useful for supplying variable values but you can initialize constants with it, for example
Code:
Private Sub Class_Initialize()
   myDateValue = Date
End Sub
 
Thank you,

I suspected as much...

Randall Vollen
Merrill Lynch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top