|
-
Mar 24th, 2002, 09:39 AM
#1
Thread Starter
Junior Member
How can different forms use the same instance of a DLL's class?
Hi!
I have a simple question.
How do different forms in a Standard EXE project use the same reference to a DLL's class?
How do I instantiate the object in one form,and use it in that form, as well as other forms in the Project?
If I use:
Dim DBMOD as DatabaseModule.DBCLASS
Private sub Sub Form1_Load
Set DBMOD = New DatabaseModule.DBCLASS
End Sub
How do I use the same object DBMOD in my other forms?? It should be instantiated in one form and then used again in that form as well as other forms(the same instance of it).
Please help!!! thanks
Last edited by saltrange; Mar 24th, 2002 at 09:48 AM.
-
Mar 24th, 2002, 03:47 PM
#2
Just declare it in a standard module instead like this:
VB Code:
'in a module
Public DBMOD as New DatabaseModule.DBCLASS
-
Mar 24th, 2002, 05:26 PM
#3
Thread Starter
Junior Member
Edneeis,
that looks fine, but the problem is that you cannot Dim it WithEvents.
In fact, I tried using WithEvents in the forms, but it doesnt accept it.
Is there any solution?
-
Mar 24th, 2002, 05:43 PM
#4
If it didn't work in the forms then maybe it doesn't have events.
Otherwise, if this is a dll you made, then to make a dll public across a project you can switch everything to a callback type situation, or you can (maybe although it'll be a lil bit of a pain) have each form keep its own private withevents version and then have one master public non event version, then when a form loads set the form one to the same instance as the public one. I don't know if you have one with events and one without, never tried it.
-
Apr 13th, 2002, 10:15 PM
#5
there are two ways
1) either at the top of form1 u delcare
public DBMOD as DatabaseModule.DBCLASS and the form 2 would reference this object as form1.dbmod
2) create a module and declare it globally..
public dbmod as databasemodule.dbclass
then all the forms could use this as dbmod..
-
Apr 18th, 2002, 10:59 PM
#6
Addicted Member
You could try this, too.
In Form1--------------------------------------------------------------------
private withevents DBMOD as DatabaseModule.DBCLASS
Form1_load
Set DBMOD = NEW DatabaseModule.DBCLASS
Form2.SetRef DBMOD
End Sub
----------------------------------------------------------------------------
Then In Form2----------------------------------------------------------------
private withevents m_DBMOD as DatabaseModule.DBCLASS
Public Sub SetRef (DBMOD as DatabaseModule.DBCLASS)
set m_DBMOD = DBMOD
End Sub
-------------------------------------------------------------------------
That which does not kill us, only makes us stronger. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|