Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help me in Calling a form from one project if it resides in another !

kishore_peddikishore_peddi Member Posts: 176

Hi,

I have one form(form1.frm) in one project(Project1.vbp). I want to call this form from another project(Project2.vbp) where i am currently residing. Please help me how to call it. Please send the syntax for it.How to call form (form1.frm) if the projects belong to the same group and if they belong to different groups.

ThanX in advance for your patience and Time.

Bye...
Cheers.
Kishore.

Comments

  • infidelinfidel Member Posts: 2,900
    : I have one form(form1.frm) in one project(Project1.vbp). I want to call this form from another project(Project2.vbp) where i am currently residing. Please help me how to call it. Please send the syntax for it.How to call form (form1.frm) if the projects belong to the same group and if they belong to different groups.

    You can always add the same form file to multiple projects. The only other option is to make Project1 an ActiveX project and encapsulate the form properties and methods with a class.
  • kishore_peddikishore_peddi Member Posts: 176

    : : I have one form(form1.frm) in one project(Project1.vbp). I want to call this form from another project(Project2.vbp) where i am currently residing. Please help me how to call it. Please send the syntax for it.How to call form (form1.frm) if the projects belong to the same group and if they belong to different groups.

    :
    : You can always add the same form file to multiple projects. The only other option is to make Project1 an ActiveX project and encapsulate the form properties and methods with a class.
    :

    Can i call it like (CALL Project1.Form1) from project2 ? ? ?
  • infidelinfidel Member Posts: 2,900
    : Can i call it like (CALL Project1.Form1) from project2 ? ? ?

    Only if Project1 is an ActiveX project that contains a class that encapsulates a form.

    Create an ActiveX DLL project and name it FormClasses. Add a class to it named CForm1 and add a form to the project named FForm1.

    Add any of the form's properties, events, or methods that you want to use to the class.

    For example, in the CForm1 class:

    [code]
    Private WithEvents frm as Form

    Private Sub Class_Initialize()

    Set frm = New FForm1

    End Sub

    Public Sub ShowModal

    frm.Show vbModal

    End Sub
    [/code]

    Then, in your other project you can add a reference to the FormClasses DLL and use it like this:

    Dim frm as FormClasses.CForm1
    frm.ShowModal

    You'll have to be careful in coding FForm1 to make sure it doesn't unload itself from memory. The class CForm1 should have complete control over the form.

  • h4xx0rh4xx0r Member Posts: 43
    : : Can i call it like (CALL Project1.Form1) from project2 ? ? ?
    :
    : Only if Project1 is an ActiveX project that contains a class that encapsulates a form.
    :
    : Create an ActiveX DLL project and name it FormClasses. Add a class to it named CForm1 and add a form to the project named FForm1.
    :
    : Add any of the form's properties, events, or methods that you want to use to the class.
    :
    : For example, in the CForm1 class:
    :
    : [code]
    : Private WithEvents frm as Form
    :
    : Private Sub Class_Initialize()
    :
    : Set frm = New FForm1
    :
    : End Sub
    :
    : Public Sub ShowModal
    :
    : frm.Show vbModal
    :
    : End Sub
    : [/code]
    :
    : Then, in your other project you can add a reference to the FormClasses DLL and use it like this:
    :
    : Dim frm as FormClasses.CForm1
    : frm.ShowModal
    :
    : You'll have to be careful in coding FForm1 to make sure it doesn't unload itself from memory. The class CForm1 should have complete control over the form.
    :
    :

    Methinks that that is over complicated. When you open project 2, just click Project > Add Form on the menu bar. Then find the form you want. You dont need to do it at run time. I'm pretty sure that is the solution. Dont flame me if I read the question wrong.

  • infidelinfidel Member Posts: 2,900
    : Methinks that that is over complicated. When you open project 2, just click Project > Add Form on the menu bar. Then find the form you want. You dont need to do it at run time. I'm pretty sure that is the solution. Dont flame me if I read the question wrong.

    That's my first thought too, but he/she seemed determined to call a form residing in another project.
  • h4xx0rh4xx0r Member Posts: 43
    : : Methinks that that is over complicated. When you open project 2, just click Project > Add Form on the menu bar. Then find the form you want. You dont need to do it at run time. I'm pretty sure that is the solution. Dont flame me if I read the question wrong.
    :
    : That's my first thought too, but he/she seemed determined to call a form residing in another project.
    :

    Well sometimes life aint fair is it. Just add in from within VB, unless you reverse engineer Visual Basic and rewrite it in your own personal use. The latter I think is not feasible, so stick with adding it to your project before hand.
  • Andre YoungAndre Young USAMember Posts: 0

    ________ { http://forcoder.org } free video tutorials and ebooks about / Ruby, R, Visual Basic, Java, Objective-C, Go, PHP, Python, C++, Delphi, Swift, Perl, MATLAB, C, C#, Visual Basic .NET, PL/SQL, JavaScript, Assembly, Scratch Rust, Apex, Alice, SAS, ABAP, COBOL, Lisp, Julia, ML, Scala, Scheme, Logo, F#, Dart, D, LabVIEW, FoxPro, Ada, Fortran, VBScript, Kotlin, Clojure, Erlang, Transact-SQL, Prolog, Awk, Crystal, Lua, Bash, Hack / ___

Sign In or Register to comment.