VB Project Groups
I have Created Project Group having Two Projects Project1 & Project2
Now from Project2 i want to access(manipulate) form/module/Class under Project1
How can i do that.
What exactly is use of more then one project under one group
Desktop
I have Created Project Group having Two Projects Project1 & Project2
Now from Project2 i want to access(manipulate) form/module/Class under Project1
How can i do that.
What exactly is use of more then one project under one group
by gbworld
Click on one of the files in project2 (in the project explorer or open a form or code window for something in project2. Go to the project menu and add a reference to project1.
You can now create an instance of an object in project1 via early binding like:
Dim objForm as Project1.Class1
Set objForm = New Project1.Class1
MyVar = Class1.Method(InputVar)
Project becomes the DLL name and the class module becomes the class. Think about ADO.
Dim objConn as ADODB.Connection
The DLL goes by the monicker ADODB, while the class is connection. In most cases, if you instanciate something like MyDLL.MyClass, you will actually find a DLL called MyDLL, which will also be the project name. This is not 100% true, esp. in C++ COM DLLs.By the way, this is exactly what you do to create and test n-tier applications. My normal method is to include a sample EXE for each DLL to unit test it.
Gregory A. Beamer
MCP: +I, SE, SD, DBA
by gbworld
One more thing to add. If you do not want to create a reference, you can always late bind your objects like so:
Dim objMyObject as Object
Set objMyObject = _
CreateObject("Project1.MyClass")
I do not recommend late binding, although CreateObject() is a nice addition as New has some real problems in MTS. If you plan on using MTS, look at MSDN on CreateInstance. You have to use the MTS ObjectContext to create an instance. In Windows 2000, use COM+ instead of MTS.
-- Greg
by nssidhuusa
by nssidhuusa
Firstly thank you for the reply
I am takling about situation where bothe project ( project1 & project2 are standard exe & i want to access forms/Class within each other)
by glen_mcleod
You can't access a standard .exe's class modules from *anywhere* but itself.
To do what you want, you have to make Project1 an ActiveX .exe and make the classes you want to access public.
Glen
by nssidhuusa
by nssidhuusa
This discussion is closed to new replies.
Sort by Trending