我試圖從啓動窗體中按鈕的事件處理程序實例化的單獨的類修改應用程序啓動窗體上的控件。從外部類設置文本值
這是在主窗體的點擊收聽:
Sub Button1Click(sender As Object, e As EventArgs)
Dim changer As New Changer()
changer.dochange
End Sub
這是類換:
Public Class Changer
Sub dochange
'ignore this part
Dim window As Form1
window = New Form1()
window.Show
'this is where i have a problem:
Dim bunz As MainForm
bunz = New MainForm()
bunz.label1.Text = "sometext"
End Sub
End Class
我甚至成立了我的LABEL1,以便它是公共的,但文字仍然不會改變。哪裏不對?
你永遠不會顯示你的'bunz'表單,這個代碼示例是否完整? – Kratz