我尝试使用此代码来声明一些字符串,该字符串将在我的应用程序表单中充当给定的控件。
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Test12 As Control = Controls("Button1")
Test12.Text = "Working"
End Sub
但是,我得到Test12的值是'NULL',如下所示。我已确认我的表单包含控件名称为 Button1
答案 0 :(得分:0)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Test12 As Control = PanelName.Controls("Button1") 'Edited Line
Test12.Text = "Working"
End Sub
PanelName 是包含您的控件的面板的名称" Button1"