我有兩個按鈕「開始」按鈕和「停止」按鈕。我通過單擊開始按鈕來運行程序。我想在啓動按鈕期間停止程序。但該計劃將不會迴應,直到開始buttun完成工作。在開始的時候我該如何檢查stop stoptun。我聽說過線程,但我不知道我該怎麼做。按鈕單擊另一個內部的事件
Private Sub Button_Start (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
//my code
//check always if the user push stop if no continue if yes go to this sub
//my code
end sub
Private Sub Button_Stop (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
stopClick = True
Dim Response As Integer
Response = MessageBox.Show("Do you really want to exit?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Response = vbYes Then
Me.Close()
End If
End Sub
您需要四個空格才能在此站點縮進您的代碼塊。嘗試命名你的控件。 Button1是否啓動? Button3是否停止? – LarsTech
yes按鈕1是開始,按鈕3是停止 – user3556795
@ user3556795充分尊重:爲什麼您聲明'響應'爲[Integer](http://msdn.microsoft.com/zh-cn/library/06bkb8w2.aspx) ,爲其分配一個[DialogResult](http://msdn.microsoft.com/en-us/library/system.windows.forms.dialogresult(v = vs.110).aspx),並將其與[MsgBoxResult]( http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.msgboxresult(v=vs.110).aspx)? –