How to force the class Shared New to execute at start up when classes names are unknown and the
How to force the class SharedNew to execute at start up when classes names are unknown and the application don’t know how many classes there are?
Hi All,
Yesterday I got help to CreateObjectByName. Today my problem is I that don’t know the names of the classes and I don’t know how many classes there are in the application!
(This is also a kind of luxury problem. The work around is that every time I write and add a new particular device class to the application, I manually update the deviceNameList with the name of the device class. But I want this automatically.)
A possible(?) elegant)?) solution may be that each class has a shared new procedure like:
ClassAclass
SharedSubNew()
deviceNameList.Add(deviceTypeShared)
EndSub
…..
End Class
Thereby each particular class puts it name (deviceTypeShared) into the deviceNameList that is later presented to the user in a combo box. The user select a device from the combo box and the device is created withCreateObjectByName.
The problem is that theSharedSubNewis not executed when the application starts up. Only when something in the class is first called. Can I foolSharedSubNewso it executed directly. OR do I need som reflection method like:
For each aClass in Assembly.ClassCollection
If aClass.hasSharedNew then aClass.new
Next
Well, the only problem is: how do I do it?
I hope there is a elegant solution for this problem.
Regards
Csaba

