Reputation: 6854
In vb6, i can do :
set object=new class
where object is a Object and Class is a class defined in the code.
Now, i want to do the same dynamically, i want to do something like:
set object=createobject("class")
but it fail because createobject is apparently for activex registered class and not class modules.
Upvotes: 0
Views: 4611
Reputation: 1873
I hope the reason you want to do this is to mimic some sort of interface-like functionality, otherwise it's probably not an ideal solution.
Anyway, you could create a method that gives back a different class depending on the string you provide.
function myClassCreatingFunction(className)
select className
case: "Class1"
set myClassCreatingFunction = new Class1
exit function
...
end select
end function
Upvotes: 3
Reputation: 41
If you put the class in question in a separate VB6 OCX, you will be able to use createObject to create them on-the-fly.
Upvotes: 4