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

    Sending information from Form1 to Form2

    Hi,

    I am trying to send information from Form1 to Form2 in VB.NET.

    I got 2 radiobuttons on Form1. When we click them Form2 opens. when I click a button on Form2 i need to know which radio button was clicked on form1.

    In Form1:radiobutton clicked: open form2

    Dim myform2 as Form2
    myform2.Show()

    -------------

    in form 2 button1 cilcked:

    Dim myform1 as Form1

    If myform1.radiobutton1.checked then // I am not able to get the information here.
    Msgbox("radiobutton 1 clicked")
    Else
    Msgbox("radiobutton 2 clicked")
    End If

    Can anyone help me how to get the information from Form1.

    Thank you.

  2. #2
    Join Date
    Jul 2005
    Posts
    27

    Re: Sending information from Form1 to Form2

    In Form1:radiobutton clicked: open form2

    Dim myform2 as New Form2
    myform2.myform1 = me
    myform2.Show()

    -------------

    in form 2 button1 cilcked:

    Dim myform1 as Form1

    If myform1.radiobutton1.checked then // I am not able to get the information here.
    Msgbox("radiobutton 1 clicked")
    Else
    Msgbox("radiobutton 2 clicked")
    End If


    Becarefull for this will reference everything on form1 with Form2. Better to just create a variable to hold the required information you want displayed in Form2. I.E.:

    Dim myform2 as New Form2
    myform2.checkedRadio = radiobutton1.text
    myform2.Show()

    -------------

    in form 2:

    Dim checkedRadio as string

    Msgbox(checkedRadio)

  3. #3
    Join Date
    Jul 2005
    Posts
    7

    Re: Sending information from Form1 to Form2

    I have used a variable to hold the information.
    Thanks a lot. It was very helpful.

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