Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Including a reference in a Class 1

Status
Not open for further replies.

dubeaum

Programmer
Joined
Jan 30, 2002
Messages
7
Location
CA
We are trying to generalize some class. For example, we have a class that use FSO. We want to be able to use this class without adding the reference in the project. Is there a way to do it in the class ? Something like an #include in C or an Import in Java. We want to make the class easyer to re-use.

Thanks a lot.
 
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
 
Thanks a lot. It's too easy !
 
Here's another one. Can we do the same thing with a class that is not included in the project. For example, I have a class named clsPdfWriter that need the class clsRegistry. I add clsPdfWriter in the project, but I don't want to add clsRegistry.
 
I think the only way to get what you want is to move clsRegistry into a separate DLL. Then you can access it by late binding (using CreateObject()).

It might be worth while to check performance using CreateObject() against explicitly including a project reference: late binding is slower because less is known at runtime about the referenced object. If your use of the called class(es) is light then it probably won't make any difference.

Mike
 
Thanks.

The use of the called class is light, so performance is not an issue.

I will still try to find a way to do it without a dll. We are trying to re-organize our dev strategy to remove as much dll as possible (for an easier installation process). And we try to re-use classes as much as we can. We are in a process of generalizing our classes and modules.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top