i have in vb6 2 proyects in one.....now there group into one....but from proyect 1 how can i call a form from proyect 2....

Example

From Proyect1 From1 a Comand Click To open or

Call Proyect2 Form2 To show....

Please help if is posible.....

Dani AI

Generated

Short answer: you cannot directly "call Project2.Form2" from a different VB6 project the way you call a form inside the same project. and pointed in the right direction — VB6 lets one project talk to another only through COM-exposed types or by sharing the form/code in the same project. Below are practical ways to achieve what wants, plus cautions.

One simple fix: add Project2's form to Project1 (Project -> Add File -> select the .frm/.frx). Once the form code is in the same project you can use the normal Form2.Show.

A cleaner, reusable approach is to expose the UI from Project2 via a COM component:

  • Put the form inside an ActiveX DLL (or add a class that calls the form).
  • Expose a Public method (for example, ShowForm) on a creatable class.
  • In Project1 add a Reference to that DLL or the project in the same Project Group and call the class method to show the form.

A very different route (if Project2 must stay a separate EXE) is to have Project2 expose a COM server (ActiveX EXE) or listen for IPC (sockets, named pipes, Windows messages). That works but adds cross-process caveats: UI runs in the other process, parenting/activation and modal behavior can differ, and COM marshaling introduces lifetime/threading issues.

Example (conceptual):

' In Project2 (ActiveX DLL): Class CForm2
Public Sub ShowForm()
    Form2.Show
End Sub

' In Project1 after adding a reference:
Dim w As Project2.CForm2
Set w = New Project2.CForm2
w.ShowForm

Cautions: watch form/default-instance differences, name conflicts, and whether you want in-process (ActiveX DLL) or out-of-process (ActiveX EXE) behavior. If reuse is the goal, factor shared UI/logic into a DLL rather than trying to reach across separate standard EXEs.

Recommended Answers

All 2 Replies

It is not possible. Projects can be referenced only as COM interfaces.

that is not possible

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.