like i have form 1 and form 2
and i have a integer on form 1 called x
how do i get this to show up on form 2?
Printable View
like i have form 1 and form 2
and i have a integer on form 1 called x
how do i get this to show up on form 2?
vb.net Code:
' Form 1 code Friend x As Integer Private Sub Button1_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs _ ) Handles Button1.Click Dim frm2 As New Form2 frm2.frm1 = Me frm2.ShowDialog() frm2.Dispose() End Sub ' Form2 code Friend frm1 As Form1 Private Sub Form2_Load( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs _ ) Handles MyBase.Load MessageBox.Show(frm1.x) End Sub
Congratulations! You are our 1 millionth customer here at "how do I pass data from one form to another".
http://www.vbforums.com/showthread.php?t=466253
That's the loosest possible solution short of putting everything in a module. If the second form requires just one piece of data from the first form then it's a far better idea to pass just that piece of data rather than a form reference. Passing the data to a constructor is preferable if the second form MUST have that data. Otherwise a public property of the second form should be set from the first form.Quote:
Originally Posted by Deepak Sakpal