starcraft Posted July 18, 2003 Posted July 18, 2003 How do i stop a loop in button1_click with button2_click? Quote
Ariez Posted July 18, 2003 Posted July 18, 2003 When you have a loop in a sub, your application is not responsive when its executing unless you use multithreading. Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
*Experts* Volte Posted July 18, 2003 *Experts* Posted July 18, 2003 If he is using Application.DoEvents it will. You can do this:Private keeplooping As Boolean = True Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Do While keeplooping Application.DoEvents() 'other stuff Loop End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click keeplooping = False End IfThat'll turn off the boolean variable which will cause the loop to stop after its next iteration (it will not break out of the middle of the loop). Quote
Ariez Posted July 19, 2003 Posted July 19, 2003 I've seen it used just to refresh breefly enough to repaint the form and loose it again to process. Quote Auto-suggestion: "I have a life" Uncontroled thinking: "So what the.."
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.