表格1代码:
Public Class Form1
Public x As String = "msg from form2"
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Form2.Show()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.TextBox1.Text = Me.TextBox1.Text
TextBox2.Text = Form2.x
End Sub
End Class
表格2代码:
Public Class Form2
Public x As String = "msg from form1"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form1.TextBox1.Text = Me.TextBox1.Text
TextBox2.Text = Form1.x
End Sub
End Class