sublimation
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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°)
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°)
ASKER
Cheers guys.