VB如何实现打开窗体 填写后返回计算
主窗体点击按钮,打开一个窗体,窗体上有多个文本框,填写好数据后关闭,返回到主窗体,点击计算按钮,能够根据刚才打开的窗体中填入的数据进行相应的运算...
主窗体点击按钮,打开一个窗体,窗体上有多个文本框,填写好数据后关闭,返回到主窗体,点击计算按钮,能够根据刚才打开的窗体中填入的数据进行相应的运算
展开
展开全部
在Form1里声明变量a、b、c
添加Button1、Button2、TextBox1
并且再Button1的Click事件中写出计算方法
Button2的Click事件是Form2的Show
Public Class Form1
Friend a, b, c As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = a + b + c
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.Show()
End Sub
End Class
添加windows窗体Form2,然后在Form2里添加TextBox1、TextBox2、TextBox3
在Form2的FormClosing事件中将TextBox里的值传递给Form1的变量a、b、c
Public Class Form2
Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Form1.a = CInt(Me.TextBox1.Text)
Form1.b = CInt(Me.TextBox2.Text)
Form1.c = CInt(Me.TextBox3.Text)
End Sub
End Class
添加Button1、Button2、TextBox1
并且再Button1的Click事件中写出计算方法
Button2的Click事件是Form2的Show
Public Class Form1
Friend a, b, c As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = a + b + c
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.Show()
End Sub
End Class
添加windows窗体Form2,然后在Form2里添加TextBox1、TextBox2、TextBox3
在Form2的FormClosing事件中将TextBox里的值传递给Form1的变量a、b、c
Public Class Form2
Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Form1.a = CInt(Me.TextBox1.Text)
Form1.b = CInt(Me.TextBox2.Text)
Form1.c = CInt(Me.TextBox3.Text)
End Sub
End Class
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询