I have 2 forms shown below. Form1 has a button that opens Form2. Form2 has a button that (I wish) puts text in a textbox on Form1
This is about as bare bones as it gets. No one I've talked to knows what to do. It appears that everytime you click the button on Form2 it creates another form. This can't be that difficult, I must be missing something simple. I can do this in VB6.
'============== ' FORM 1 '============== Public Class Form1 Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm2 As New Form2 frm2.ShowDialog()
End Sub End Class '============== ' FORM 2 '==============
Public Class Form2 Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim frm1 As New Form1 frm1.TextBox1.Text = " TEST " End Sub End Class
It looks to me the reason your getting a new form is you are creating a new on, in your dim statement, frm1 as new form1. should it not be
form1.testbox1.text = "test"
as the only on_click statement? You shouldnt have to dim the form it is already active, and your are just supplying a value to a control with in a live form. Just my thoughts.