dynamic object instanciation

  • Thread starter Thread starter Pierre
  • Start date Start date
P

Pierre

Hello,

I would like to create an instance of a class, and be able to select
dynamically, durint the program, the class of this object.
Is it possible ?
And how ?

set myobj = new("myclass") ???

Thanks.

Best Regards.

Pierre.
 
Why? Given that the objects are at one of the lowest (if NOT the lowest)
foundations, I can't imagine how you would have code that would
function consistently across different types of objects.
 
I would like to create an instance of a class, and be able to select
dynamically, durint the program, the class of this object.

There is a limited form of inheritance in VBA OO system:

Object can be a parent of practically anything:

dim o as Object

if version = "DAO" then
set o = new DBEngine

else
set o = CreateObject("oldedb.connection")

end if


A few other examples are regularly used:

dim c as Control

set c = Screen.ActiveControl

Select Case c.ObjectType
Case "ListBox" : c.RowSource = ""
Case "TextBox" : c.Value = Null
Case "CommandButton" : c.Value = True

End Select

and so on. If you want proper OOH inheritance, then you'll have to move
up to dot-Net.

Tim F
 
Back
Top