Link to home
Start Free TrialLog in
Avatar of typetoit
typetoit

asked on

Use a variable for Class Name in Classic ASP

I have several classes [ClassA, ClassB, ClassC].  I want to create an instance of one of the classes but the name of the class is in a variable [myClass].  I am wondering how I would use the variable to make any instance of one of my classes.

For example, I would like to do something like this:
Set objClass = New myClass

Open in new window


Can this be done?
Avatar of Big Monty
Big Monty
Flag of United States of America image

i'm a bit unclear on what you're asking but set instantiate a class and set it to a reference (or variable), is exactly how you have it.

here's a good read on OOP Programming in ASP
Avatar of typetoit
typetoit

ASKER

I want to instantiate a class where the name of the class is stored in a variable.  
For example, myClass could be ClassA or ClassB.  

Dim myClass, objClass

myClass = "ClassA"
Set objClass  = New myClass

In the above example, I want to instantiate ClassA using myClass.  Will this work?
SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial