Please help me pass a value from form2 back to form1. I am obviously a novice.
Form1 has textbox displaying the client's order, and a button to place order. Form1.button_click pops up form2.
Form2 displays listbox with multiple choices.
Form2 also has button to accept order, which will then be displayed in form1.textbox.
Form2.button_click code:
Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccept.Click
Dim strOrders As String = ""
Dim strOrder As String = ""
Dim frm1 As Form1
'create a string from the selected lines in list box
For Each strOrder In ListBox1.SelectedItems
strOrders &= strOrder
Next
'now pass the string back to form1's text box
frm1.TextBox1.Text = strOrders
'compiles but will not run
'error: Object reference (frm1) not set to an instance of an object.
End Sub
Obviously I do not know how to refer back to form1 and its textbox from form2. Thanks for any help.
Form1 has textbox displaying the client's order, and a button to place order. Form1.button_click pops up form2.
Form2 displays listbox with multiple choices.
Form2 also has button to accept order, which will then be displayed in form1.textbox.
Form2.button_click code:
Private Sub btnAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccept.Click
Dim strOrders As String = ""
Dim strOrder As String = ""
Dim frm1 As Form1
'create a string from the selected lines in list box
For Each strOrder In ListBox1.SelectedItems
strOrders &= strOrder
Next
'now pass the string back to form1's text box
frm1.TextBox1.Text = strOrders
'compiles but will not run
'error: Object reference (frm1) not set to an instance of an object.
End Sub
Obviously I do not know how to refer back to form1 and its textbox from form2. Thanks for any help.