dynamically creating instances of classes 
Author Message
 dynamically creating instances of classes

 Hi folks,

  In my VB application I have a number of classes. The names of which
are to be retrieved from the database. I wish to create instances of
these classes dynamically when the name of the class is
provided/available from the recordset. How do I create the class's
object when only the name is available.

To clarify the matter a little more, let me give you an example which
hopefully will shed some more light on my problem:

Dim sClassName as String
sClassName = m_rs.Fields("class_name").Value

How to instantiate an object of type sClassName
dim AnObject as object
set AnObject = new <<<sClassName>>>

I'd greatly appreciate your suggestions to resolve this issue.
Thanks in advance,
-abhijeet
--
Abhijeet Kulkarni
(319)366-0973 *4233, CCH Incorporated

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 16 Feb 2003 03:00:00 GMT  
 dynamically creating instances of classes

Abhi,

Quote:
>How do I create the class's
>object when only the name is available.

Check out VB's intrinsic CreateObject function, and simply
use the generic Object data type.

--
Brad Martinez, http://www.mvps.org
Please direct questions/replies to the newsgroup

Quote:

> Hi folks,

>  In my VB application I have a number of classes. The names of which
>are to be retrieved from the database. I wish to create instances of
>these classes dynamically when the name of the class is
>provided/available from the recordset. How do I create the class's
>object when only the name is available.

>To clarify the matter a little more, let me give you an example which
>hopefully will shed some more light on my problem:

>Dim sClassName as String
>sClassName = m_rs.Fields("class_name").Value

>How to instantiate an object of type sClassName
>dim AnObject as object
>set AnObject = new <<<sClassName>>>

>I'd greatly appreciate your suggestions to resolve this issue.
>Thanks in advance,
>-abhijeet
>--
>Abhijeet Kulkarni
>(319)366-0973 *4233, CCH Incorporated

>Sent via Deja.com http://www.deja.com/
>Before you buy.



Mon, 17 Feb 2003 03:00:00 GMT  
 dynamically creating instances of classes
Hi back Brad,

  I think I tried using CreatObject function. It works only when
creating instances of a DLL and not instances of any classes present in
the same project. Or am I missing here anything?
Could you please qualify this?
Thanks,
-abhi



Quote:

> Abhi,

> >How do I create the class's
> >object when only the name is available.

> Check out VB's intrinsic CreateObject function, and simply
> use the generic Object data type.

> --
> Brad Martinez, http://www.mvps.org
> Please direct questions/replies to the newsgroup


> > Hi folks,

> >  In my VB application I have a number of classes. The names of which
> >are to be retrieved from the database. I wish to create instances of
> >these classes dynamically when the name of the class is
> >provided/available from the recordset. How do I create the class's
> >object when only the name is available.

> >To clarify the matter a little more, let me give you an example which
> >hopefully will shed some more light on my problem:

> >Dim sClassName as String
> >sClassName = m_rs.Fields("class_name").Value

> >How to instantiate an object of type sClassName
> >dim AnObject as object
> >set AnObject = new <<<sClassName>>>

> >I'd greatly appreciate your suggestions to resolve this issue.
> >Thanks in advance,
> >-abhijeet
> >--
> >Abhijeet Kulkarni
> >(319)366-0973 *4233, CCH Incorporated

> >Sent via Deja.com http://www.deja.com/
> >Before you buy.

--
Abhijeet Kulkarni
CCH Incorporated

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 18 Feb 2003 00:17:28 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Dynamically creating classes...

2. Handling Events of Dynamically Created Classes/Objects

3. create instance of a class from a string

4. Create an instance from the class name?

5. Using reflection to create class instance

6. Creating a new instance of Winsock in a Class Module

7. ASP - create in just script instance of class provided in current page with different language

8. Using New to create instances of a class in MTS componant

9. Want to create only ONE instance of class

10. Using New to create instances of a class in MTS componant

11. Create Instance of class in running activeX.exe??

12. Create an instance of a Timer obeject in a class

 

 
Powered by phpBB® Forum Software