classvb6constructor

How have you dealt with the lack of parameterized constructors in VB6?


VB6 classes have no parameterized constructors. What solution have you chosen for this? Using factory methods seems like the obvious choice, but surprise me!


Solution

  • I usually stick to factory methods, where I put the "constructors" for related classes in the same module (.BAS extension). Sadly, this is far from optimal since you can't really limit access to the normal object creation in VB6 - you just have to make a point of only creating your objects through the factory.

    What makes it worse is having to jump between the actual object and your factory method, since organization in the IDE itself is cumbersome at best.