1 Attachment(s)
[RESOLVED] [EXCEL] UserForms: Interrupt an Event by another one
Hi guys,
really could use some help! :)
Trying to keep this simple:
I have a simple UserForm with 2 buttons. The run button sets a global variable to true and starts a loop, the cancel button just sets the global variable to false which is tested inside the loop.
Code:
Option Explicit
Dim blState As Boolean
Private Sub CommandButton_Cancel_Click()
blState = False
End Sub
Private Sub CommandButton_Run_Click()
Dim i As Integer
i = 0
blState = True
While blState = True And i < 10000
Debug.Print i
i = i + 1
Wend
End Sub
Problem is: As soon as the loop is entered, the UserForm will react to nothing. :confused:
Maybe this is the normal behavior, but I need a way to stop the loop if the user decides to cancel out.
Any ideas? That would be great!!!!
I'm attaching the Workbook.
cheers,
ray
Re: [EXCEL] UserForms: Interrupt an Event by another one
Code:
Option Explicit
Dim blState As Boolean
Private Sub CommandButton_Cancel_Click()
blState = False
End Sub
Private Sub CommandButton_Run_Click()
Dim i As Integer
i = 0
blState = True
While blState = True And i < 10000
DoEvents '<~~ Add this to your code
i = i + 1
Wend
End Sub
Re: [EXCEL] UserForms: Interrupt an Event by another one
Something things are sooo simple, but you just don't see them :blush:
I new i could rely on you koolsid :cool:
Thanx a million.... again :thumb:
cheers,
ray