Click to See Complete Forum and Search --> : Sending information from Form1 to Form2


siddhub
July 19th, 2005, 07:22 PM
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.

JSawyer
July 19th, 2005, 07:34 PM
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)

siddhub
July 21st, 2005, 04:55 AM
I have used a variable to hold the information.
Thanks a lot. It was very helpful.