Results 1 to 3 of 3

Thread: [RESOLVED] [EXCEL] UserForms: Interrupt an Event by another one

Threaded View

  1. #1

    Thread Starter
    New Member RaytracerFFM's Avatar
    Join Date
    Jun 2010
    Location
    Frankfurt, Germany
    Posts
    15

    Resolved [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.

    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
    Attached Files Attached Files
    Last edited by RaytracerFFM; Jun 14th, 2010 at 11:29 AM.

    If your query has been Solved, please mark it as such in the top menu via Mark Thread Resolved under Thread Tools

    Was a post helpful? Then you might care to rate it by clicking Rate This Post on the lower left hand side of it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width