I can't seem to pass values from Form1 to Form2 when i click
btnSubmit_click.
Form1:
txtName
txtAge
Form2:
Dim Form2 As New frmMain2()
strName = Form2.txtName.Text
strAge = Form2.txtAge.Text
lblName.Text = strName <- doesnt show! :(
Printable View
I can't seem to pass values from Form1 to Form2 when i click
btnSubmit_click.
Form1:
txtName
txtAge
Form2:
Dim Form2 As New frmMain2()
strName = Form2.txtName.Text
strAge = Form2.txtAge.Text
lblName.Text = strName <- doesnt show! :(
txtName and txtAge in Form2 will be empty (unless otherwise defined at design time) because you have only just created an instance of the form.
From what you say you want, assuming that Form1 contains the controls txtName and txtAge, you would do something like this:
VB Code:
'Form1 code Private Sub btnSubmit_Click(ByVal sender as System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim Form2 As New frmMain2 With Form2 .txtName.Text = txtName.Text .txtAge.Text = txtAge.Text End With End Sub
I know this is most probably wrong but it's the best I could do with your example as it conflicts with itself.