Reputation: 35
I have used Application.DoEvents()
in my code so that I can exit a loop with a button press, I am having an issue where I have to click on the screen before I can press this exit button, thus needing two clicks. This happens every time I play then try to stop the program, without closing it. How would I fix this?
Do While StopProgram = False
Application.DoEvents()
RadianAngle = Angle * PlaceHolder
Me.Refresh()
If DirectionPositive = False Then
Angle += 1
If Angle = 51 Then
Angle = 49
DirectionPositive = True
End If
ElseIf DirectionPositive = True Then
Angle -= 1
If Angle = -51 Then
Angle = -49
DirectionPositive = False
End If
End If
Loop
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
StopProgram = False
RunningProgram()
End Sub
Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
StopProgram = True
End Sub
Upvotes: 1
Views: 89
Reputation: 15813
One workaround: It will work OK if you use MouseDown instead of Click events.
Upvotes: 1