CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2001
    Posts
    44

    working with 2 forms in a project

    i created 2 forms in a project. one form called frmMain and other is frmCustom.
    form frmCustom have the textbox input for "height" and "width".how do i get the values from "height" and "width" in frmCustom to the other form "frmMain"?


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: working with 2 forms in a project

    You can refer to any control of any loaded form by name thus:

    public Sub CommandResize_Click()

    me.Width = frmCustom.txtWidth.Text

    End Sub




    HTH,
    Duncan


    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163

    Re: working with 2 forms in a project

    If I'm reading this correctly you are entering values in a textbox on one form and want to get those values to another form? You can either reference the first form frmMain.text1.text = frmCustom.text1.text or create a global variable in a module to capture the values on frmCustom and transfer them to frmMain as below:

    In code module:

    Public strHeight as String
    Public strWidth as String

    In frmCustom after entering value:

    strHeight = text1.text
    strWidth = text2.text

    In frmMain:

    text1.text = strHeight
    text2.text = strWidth




  4. #4
    Join Date
    Mar 2001
    Posts
    44

    Re: working with 2 forms in a project

    hi,
    thanks. by the way, you wrote:
    In code module:
    Public strHeight as String
    Public strWidth as String

    is it writting the above in the "standard module" .bas?




  5. #5
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163

    Re: working with 2 forms in a project

    Yes. Put the variable declations in a bas module.


  6. #6
    Join Date
    Mar 2001
    Posts
    44

    Re: working with 2 forms in a project

    what is a bas module? i mean when should i use bas module and when i should i not use it?


  7. #7
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163

    Re: working with 2 forms in a project

    Use a BAS module to declare ojects globally for use anywhere in your application. Just select Project|Add Module and save it as a .bas file.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured