-
Keddie,
you are right about constructors and destructors but you can get round it to an extent.
Say you have a class CJones
You can write an initialisation procedure, Init, say, to initialise the values in the class. (These would be user set values that cannot be set in the Class_Initialize event)
Code:
Friend Sub Init(Optional Age As Variant, Optional Height As Variant)
If Not IsMissing(Age) Then Me.Age = Age
If Not IsMissing(Height) Then Me.Height = Height
End Sub
Then you write a Public Function in a BAS module to instantiate the class.
Code:
Public Function New_CJones(Optional Age As Variant, Optional Height As Variant)
Set New_CJones = New CJones
New_CJones.Init Age, Height
End Function
Then you ask users to write:
Code:
Dim j As CJones
Set j = New_CJones(10, "1.92 Metres")
You cannot force the user to use the changed code but you can utilise this internally.
I know all that does not answer the question, but I thought you might be interested.
Cheers,
P.
-
Well thats thats almost the way i use, but i like to put them in the higher level object like directX control has it's Directdrawcreate and methods like blablablacreate or createblabla :)
Set DDraw = DirectX.DirectDrawCreate("")
-
-
Well Guess What. the contstructers for the class are the class its self, on the two drop down boxes in the vb ide, where u select an object and an event ? well goto the .cls file and seelect the class as ur object and initiate or terminate (constructor and deconstructor)
-
Not really the same thing, you can't pass any parameters to them :(
-
You can't pass parameters to the destructor anyway. For the constructor, just use an Init function. BTW - if VB7 has overloaded functions then they'll be on their way to proper OOP :)
-
VB7 will have overloading functions, as well as other OOP stuff like inheritance..finally VB will be a proper OOP language (hopefully) :)