Results 1 to 7 of 7

Thread: [HELP] Control in another form?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Posts
    6

    Question [HELP] Control in another form?

    how to control a control located in another form in .net like we did in vb 6: form1.textbox1.text=" " thanks for help!

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Posts
    6
    anyone HELP?

  3. #3
    Addicted Member Stick's Avatar
    Join Date
    Aug 1999
    Location
    Iowa
    Posts
    152

    Not so easy....but not hard

    Remember Vb.Net everthing is an object.
    So you have to call the form and the textbox.
    Code:
    Module CodeModule
    
        Public frmMainOne As System.Windows.Forms.Form
    
    End Module
    
    
    
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            frmMainOne = Me
        End Sub
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            'Gets the caption from the first form
            txtBox6.Text = frmMainOne.Text
        End Sub

    http://www.vbforums.com/showthread.p...hreadid=233092


    change
    Public frmMainOne As System.Windows.Forms.Form
    to
    Public frmMainOne As System.Windows.Forms.text
    for textboxes or change it as you need it !

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    or you can use this easy way
    VB Code:
    1. dim frm2 as new form2 'second form the control in
    2. 'this will write some text from your current window to the other
    3. frm2.Textbox1.text="blah"

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Posts
    6
    both of them don't work!

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Posts
    6
    Originally posted by Pirate
    or you can use this easy way
    VB Code:
    1. dim frm2 as new form2 'second form the control in
    2. 'this will write some text from your current window to the other
    3. frm2.Textbox1.text="blah"

    this one actually create a new form but not the original form!

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Is this what you mean ??
    Attached Files Attached Files

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