Public Class Form1
Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click
End Sub
Public Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles YurName.TextChanged
Dim Name1 As String
Name1 = YurName.Text
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim total As Integer
total = (YurName.Text.Length) + (PartName.Text.Length)
Dim cal As Integer = 0
MessageBox.Show("Name" & name1.length) ------>>>>PROBLEM
'End While
End Sub
End Class
我不知道如何将字符串“name1”从“sub textbox1_textchanged”调用到另一个“sub button1_click”
请帮助我。
谢谢你
答案 0 :(得分:0)
根本不要使用TextChanged
处理程序。你不需要它。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim total As Integer = (YurName.Text.Length) + (PartName.Text.Length)
Dim cal As Integer = 0
Dim name As String = YurName.Text
MessageBox.Show("Name" & name.length)
End Sub
答案 1 :(得分:0)
我认为你是在寻求教育目的 所以,就像访问vba一样,每当你需要在许多子程序中使用变量时,在这种情况下,“Name1”,只需将它声明为全局变量......就在
之下Public Class Form1
Dim Name1 as string