PDA

View Full Version : Sharing Modules & Classes Between Projects



martyral
2005-01-27, 05:18 PM
Has Anyone every found a simple way to Share/use Routines from one Project with another Project.
I get very tired of loading up new projects with code I know is already loaded in another Project.

Any Ideas would help me out

Thanks,
Marty Raley

Ed Jobe
2005-01-27, 05:45 PM
I have a separate dvb for library typ code. I call it Toolbox.dvb. In any project that you need to use code from the toolbox, just reference the dvb and it will automatically load when the main project loads. You will also be able to use Intellisense by starting with the toolbox's project name. The only cavaeat is you have to take a couple of extra steps if your toolbox will include class modules. But you won't have multiple copies of functions floating around.

martyral
2005-01-27, 06:34 PM
That sounds like just what I need. Can you show me how it is referenced from one to the other.

Ed Jobe
2005-01-27, 06:37 PM
In the project that will use code from the toolbox: Tools>References, check Toolbox,dvb. Then, if you are calling a sub/func from the toolbox, use the format, Project.Module.Procedure.

martyral
2005-01-27, 06:48 PM
Well, Thanks! That looks like it did it. I'll play around and see just what can be done with this new-to-me Idea.

I always try to take programming to the limits.
Limits of my knowledge that is...

Marty

jonesb33145
2007-06-19, 05:35 PM
...The only cavaeat is you have to take a couple of extra steps if your toolbox will include class modules...

This is the exact problem I am currently having in that the reference project is just classes and I am not able to access them. Could you please elaborate on the "extra steps" part?

Thanks!

Ben

Ed Jobe
2007-06-19, 05:44 PM
This is the exact problem I am currently having in that the reference project is just classes and I am not able to access them. Could you please elaborate on the "extra steps" part?

Thanks!

Ben
OK, for each class that you want to expose to use outside the toolbox, you need to change its Instancing property to PublicNotCreateable. Now other projects can see it but not create an instance. Therefore, you need to create a public module with a function that returns an instance of the class, i.e. where, ObjDbx is the name of a class in my toolbox.


Public Function CreateObjDbxClass() As ObjDbx
Dim objTemp As ObjDbx

Set objTemp = New ObjDbx
Set CreateObjDbxClass = objTemp
Set objTemp = Nothing
End Function

jonesb33145
2007-08-09, 05:23 AM
That worked beautifully...Thank you!

Ed Jobe
2007-08-09, 02:11 PM
That worked beautifully...Thank you!
That was a delayed response. ;-) You're welcome.