我的vb项目中有多个表单。 Form1是一个启动表单。有一个变量,即将整数值传递给Form2。我将Form3添加到项目中并将其作为启动表单。然后我从项目中删除它,并再次将Form1作为启动表单。但是,从那时起,Form1上的变量没有将其整数值传递给Form2。我弄乱了我的项目。有人可以帮忙???
表格1
Public i as integer
Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
i = 1
dim nf as new form2
nf.showdialog(me)
end sub
表格2
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
msgbox(form1.i)
end sub
但msgbox打印值' 0'
答案 0 :(得分:0)
好的朋友,感谢您的帮助。但是,我自己解决了。
表格1
Private Sub btn_Click(sender As Object, e As EventArgs) Handles btn.Click
dim nf as new form2
nf.f2int = 1
nf.showdialog(me)
end sub
表格2
Public Property f2int as Integer
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
msgbox(f2int)
end sub