Link to home
Start Free TrialLog in
Avatar of sublimation
sublimationFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Class Initialise VBA

Hi, can I pass parameters to the class Initialise method.

E.g

Private Sub Class_Initialize()

End Sub

Can take parameters like this:

Private Sub Class_Initialize(name As String)

End Sub

This the leads me to believe that I can then write code like this:

Dim cPerson as New Person("Peter")

But I do not seem to be able to pass a value to the class initialiser....Since the initialiser takes parameters, can somebody tell me how to pass values to them?  I was hoping to be able to pass them at initialisation.   Thanks.
ASKER CERTIFIED SOLUTION
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sublimation

ASKER

Okay, so there is no way.....
Cheers guys.
Thanks. Afterthought: the line

Private Sub Class_Initialize(name As String)

doesn't compile. It's because it's itself an implementation of the class mechanism used to fake OO in VB. When an instance is created, the "initialise" event is raised; just before it's zapped from memory, the "terminate" event is raised. They are not constructors, they are really event handlers.

(°v°)