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

    from one form to the other form

    i have 2 forms named "frmMain" and "frmCustom".

    'in frmMain
    option Explicit
    ' Global variables hold the total number of columns and rows
    private TotalCols as Integer
    private TotalRows as Integer
    private Sub Form_Load()

    TotalCols = frmCustomField.CWidth
    TotalRows = frmCustomField.CHeight
    End Sub
    --------------------------------------------------------------
    ' in frmCustom
    option Explicit
    private Sub cmdOk_Click()
    Dim CHeight as Integer, CWidth as Integer
    CHeight = Val(txtHeight.Text)
    CWidth = Val(txtWidth.Text)
    End Sub




    well, the above is part of my project and i have a problem with that.
    in frmCustom, i have 2 textboxes named "txtHeight" and "txtWidth" and i want to pass the values in "txtHeight" and "txtWidth" to frmMain. how can i get that?









  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: from one form to the other form

    Declare the variables as Public in frmMain. Then you can access the variables from frmCustom as
    FormName.VarName

    I have modified your code to do the same.


    'in frmMain
    option Explicit
    ' Global variables hold the total number of columns and rows
    public TotalCols as Integer
    public TotalRows as Integer
    private Sub Form_Load()

    TotalCols = frmCustomField.CWidth
    TotalRows = frmCustomField.CHeight
    End Sub
    --------------------------------------------------------------
    ' in frmCustom
    option Explicit
    private Sub cmdOk_Click()
    Dim CHeight as Integer, CWidth as Integer
    CHeight = Val(txtHeight.Text)
    CWidth = Val(txtWidth.Text)
    frmMain.TotalCols = CWidth
    frmMain.TotalRows = CHeight
    End Sub






  3. #3
    Join Date
    Mar 2001
    Posts
    44

    Re: from one form to the other form

    its still does not work..


  4. #4
    Join Date
    Sep 2000
    Posts
    23

    Re: from one form to the other form

    I had a similar problem just a little while ago, i wanted textbox's on the second form to display in the first form after clicking the ok button in the second form.
    ( i was going from the second form to the first, sounds like your just calling the second form )

    What i had to do was call the name of the first form like this "fMainForm."
    You are doing it differently so i don't know if that will help you but i think you have to name the form in full to get values from it (like a path statement).



  5. #5
    Join Date
    Mar 2001
    Posts
    44

    Re: from one form to the other form

    can u show me ur code so that i can try and figure it out...


  6. #6
    Join Date
    Sep 2000
    Posts
    23

    Re: from one form to the other form

    I dont have it on this computer, but see if this helps.
    Change:
    frmMain.TotalCols = CWidth
    frmMain.TotalRows = CHeight

    To:
    fMainForm.TotalCols = CWidth
    fMainForm.TotalRows = CHeight

    See if that works in the mean time.
    Did you start this project from the wizard? because if you did look in the module (top), there should be something in there that the wizard put in about nameing the form fMainForm, thats what had me stumped for a while.



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