stickleprojects Level: Moderator

 Registered: 09-09-2002 Posts: 891
|
Re: Multiple DLL's
Hi,
I don't see the issue. You have already figured out how to set a variable in a dll, so expand the idea.. as in:
You should already have a public class in DLL2, so add a property called testVariable.
When the EXE launches DLL2, set the property (objDll2PublicClass.testVariable = objDLL1PublicClass.testVariable)
When DLL2 shows the form, set the textbox.value = testVariable in the public class.
Example:
DLL1:
Class clsDLL1
public testVariable as string
end class
DLL2
Class clsDLL2
public testVariable as string
public sub ShowForm()
dim frm as frmMain
set frm=new frmMain
frm.textbox1 = me.testVariable
frm.Show
unload frm
set frm=nothing
end sub
end class
EXE
sub Main
dim objDLL1 as new clsDLL1
dim objDLL2 as new clsDLL2
objDLL1.testVariable = "fred"
objDLL2.testVariable = objDLL1.testVariable
objDLL2.ShowForm
set objDLL1 = nothing
set objDLL2 = nothing
end sub
I may be missing the point, however. Did you want the DLL2 to automatically show the value from DLL1 without the EXE setting it? If so, you have a couple of options:
1. Add the form to DLL1 instead of DLL2 and use DLL1 to hold the testVariable value in a global variable.
2. Add the ShowForm method to your class in DLL1, which can then set the variable.
3. Use an ActiveX EXE to hold the shared information - see the MSDN on creating singleton ActiveX exe's in VB.
General information on Singleton ActiveX EXEs.
Create an ActiveX EXE project.
Add a module called mdlGlobals
Add a public variable g_Server as clsServer
Add a public variable g_lngClientCount as long
Add a class called clsServer
set properties to Public / Non-Creatable
Add a class called clsClient
set properties to Public / Multi-Use
add a class_Initialize and Terminate as below
private sub class_initialize
if g_lngClientCount=0 then
set g_Server = new clsServer
end if
g_lngClientCount = g_lngClientCount + 1
end sub
private sub class_terminate
g_lngClientCount = g_lngClientCount - 1
if g_lngClientCount<=0 then
set g_server = nothing
end if
end sub
Compile this EXE.
Reference this EXE from all DLLs that you wish to share data.
Each DLL creates as many instances of clsClient that they wish, however, only 1 instance of clsServer will ever be created. Add any properties you wish to share clsServer and expose them via clsClient:
ie.
in clsServer
private m_strTestVariable as string
public property let TestVariable(RHS as string)
m_strTestVariable = RHS
end property
public property get TestVariable() as string
TestVariable = m_strTestVariable
end property
in clsClient
public property let TestVariable(RHS as string)
g_Server.TestVariable = RHS
end property
public property get TestVariable() as string
TestVariable = g_Server.TestVariable
end property
and so on...
Hope this helps,
Kieron
____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)
|