excel vba - VBA - Create a new object using the text name of the class -


Is there a way to set an object in a new instance of a class using the class name of the class?

I have a library of classes, and depending on some other variables, I have to get one of these classes on runtime.

Example I have "CTET1", "CTET2", "CTET2", "CTET3"

I will have the same work as below

  Function gate test class (not as long as) Dim strClassName string as object strClassName = "CEEST" & amp; CSTR (LNG class no) set gate test class = new instance of class (strClassName) termination function  

There is no reflection in VBA, so I do not think it is possible. You have to do something that I'm afraid of:

  Select object As per Episode 1 GetTestClass (not long longer than lngClassNo) Case 1 Set Gettest Class = New CTest1 Case 2 Set GetTestClass = New CTET 2 ... and stitched and function  

Unless your CTEist class is defined in a CF DLL, you can use CreateObject Statement. Although you have to use VB6 to create such a DLL, you can not create DLL in Excel, Access, etc.

  GetTestClass (long longer than the lngClassNo) as the GetTestClass = CreateObject set "MyDll.Cest" & amp; LngClassNo) and Function  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -