In reference to this post http://www.daniweb.com/forums/thread43763.html
I have another more specific question about passing data between forms in VB.net
I have a form with over 50 variables that I need to access on a second form and if i followed the method above, my form 2 will end up way too long and time consuming.
I'm making a complex calculation software that prompts user inputs values and calculates all those unknown variables. I need to display all the resulting values in the 2nd form. and from the 2nd form , i want to give the users an option to export all those values to an ms Excel sheet.
Here is an example of what I did in reference to the guide from the above link, Is there anyway to group the multiple properties into one for form2?
Feel free to copy and paste the code.
'form1 with a button and textbox
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Obj1, Obj2 As New Form2
Dim TDX, TBX, a As Decimal
a = TextBox1.Text 'user input value
b = 1 + a
c = 2 + a
Obj1.TDX = b
Obj2.TBX = c
Obj1.Show()
Obj2.Show()
End Sub
End Class
'form2: 2 labels
Public Class Form2
Public _b, _c As Decimal
Public Property [b]() As Decimal
Get
Return _b
End Get
Set(ByVal b As Decimal)
_b = b
End Set
End Property
Public Property [c]() As Decimal
Get
Return _c
End Get
Set(ByVal c As Decimal)
_c = c
End Set
End Property
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = _b
Label2.Text = _c
End Sub
End Class
Thank you
Sip