0

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.

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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

2 Comments

+1 You've answered the question asked. I'm not sure what magallanes is trying to do, but I'd think it has to be better to pass an Enum rather than a string?
i am trying to serialize a complex object then it can send via SOAP protocol but apparently there is not a possible way (not automatically) to convert a usable object back and to a xml.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.