vb.net 两个窗体的数据
form1中PublicaAsStringPrivateSubButton1_Click(ByValsenderAsObject,ByValeAsSystem.Event...
form1中
Public a As String
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
a = "sssssss"
Dim f2 As New Form2
f2.show()
form2中
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim f1 As New Form1
Dim b As String
b = f1.a
TextBox1.Text = b
End Sub
为什么form2里的textbox1中没有任何东西显示呢?
刚学vb,呵呵 展开
Public a As String
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
a = "sssssss"
Dim f2 As New Form2
f2.show()
form2中
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim f1 As New Form1
Dim b As String
b = f1.a
TextBox1.Text = b
End Sub
为什么form2里的textbox1中没有任何东西显示呢?
刚学vb,呵呵 展开
3个回答
展开全部
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim f1 As New Form1
Dim b As String
b = f1.a
TextBox1.Text = b
End Sub
把这段代码改成
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim b As String
b = form1.a
TextBox1.Text = b
End Sub
Dim f1 As New Form1
Dim b As String
b = f1.a
TextBox1.Text = b
End Sub
把这段代码改成
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim b As String
b = form1.a
TextBox1.Text = b
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
个人认为你的
form2中
Dim f1 As New Form1
定义一个new form1 ,所以就不 form1中的a初始是没有值的,在Button1.Click
才a才会有值,
所以才会没有值
form2中
Dim f1 As New Form1
定义一个new form1 ,所以就不 form1中的a初始是没有值的,在Button1.Click
才a才会有值,
所以才会没有值
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询