Toni
Toni

Reputation: 699

Working With multiple instance of a windows form in vb.net

I have three forms (form1, form2, form3) in a windows application using vb.net

form1 has a button (button1). Onclick of button1, I want to open form2 in such a way that it can also open multiple times. I achieved this with the code below:

Dim myForm As New Form2
myForm.Show()

Now form2 has a button (button2), and a label (label1). Onclick of button2, I want to open a single instance of form3 a dialog, so I have the code below:

form3.showdialog()

form3 has a textbox (textbox1).

My problem is that I want when I fill textbox1, I want the value to appear in label1 of form2 that opened the form3, I tried the code below, but it did not work:

form2.label1.Text = textbox1.Text

I need to update form2 (the last active one) once form3 has been closed Can anybody help me out please?

Upvotes: 1

Views: 2418

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564363

When you go to show the Form3 as a dialog, you should be able to do:

Dim f3 As New Form3
f3.ShowDialog()
Me.label1.Text = f3.textbox1.Text 'Copy the value out of the dialog

Upvotes: 1

Related Questions