I need function to Get Class by Name

  • Thread starter Thread starter Gio
  • Start date Start date
G

Gio

For example :
Dim myClass as SomeClass

Set myClass= classGet("SomeClass")

Where can I find a classGet() function?
thank you
 
Well, I can't imagine that you have that many class modules?

Perhaps 10 max?

If you have a lot, then I suspect there is some design issue at play that
could be done differently?

Since there can't be that many, then build your own "get" function. You will
have add one line of code for each time you add a new class object, but that
for a typical application not going to be much extra code..

eg:

Public Function MyGetClass(strClass As String) As Object

Select Case strClass

Case "clsBook": Set MyGetClass = New clsBook

Case "foo": Set MyGetClass = New foo

End Select


End Function

Then in code go:

Dim c As Object
Dim strC As String

strC = InputBox("what class")

Set c = MyGetClass(strC)

Not a pretty solution like your asking for, but since one is not likely to
have many class modules, then the above should be workable...
 
Well, I can't imagine that you have that many class modules?

Perhaps 10 max?

If you have a lot, then I suspect there is some design issue at play that
could be done differently?

Since there can't be that many, then build your own "get" function. You will
have add one line of code for each time you add a new class object, but that
for a typical application not going to be much extra code..

eg:

Public Function MyGetClass(strClass As String) As Object

Select Case strClass

Case "clsBook": Set MyGetClass = New clsBook

Case "foo": Set MyGetClass = New foo

End Select

End Function

Then in code go:

Dim c As Object
Dim strC As String

strC = InputBox("what class")

Set c = MyGetClass(strC)

Not a pretty solution like your asking for, but since one is not likely to
have many class modules, then the above should be workable...

I have 9 database that have to use Class that reside in a library DB
(Library.mda)
Is not possible to instancing a class if it is in an external
(library) DB .
So I need a function to put il Library.mda to get the Class and then
use it from my 9 DB.

Thank you very much.

Gio
 
Back
Top