Results 1 to 2 of 2

Thread: Interupting a program.

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    8
    I have a program that processes for a long time. I would like to be able to push a button on the form that can stop the processing if I need it to. Currently the button's code is not executed until after the processing is done. How can I make it so that the button's code is executed while the other processing is going on. Any help is greatly appreciated.

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Here's an example

    Code:
    Private StopMe As Boolean
    
    Sub Form_Load()
    StopMe = False
    End Sub
    
    Sub LongLoop()
    Dim x&
    x = 0
    
    Do While x < 10000 and StopMe = False
        x = x + 1
        DoEvents 'Important!
    Loop
    End Sub
    
    Sub Command1_Click()
    StopMe = True
    End Sub
    
    Sub Form_Unload(Cancel As Integer)
    StopMe = True
    End Sub
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

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