Well, this is similar to my other thread. Anyways, I want to have a "stop" or "cancel" button, that immediately stops the loop where it is. Not when it finishes.

Here is my current code:
VB Code:
  1. Private Sub start_Click()
  2. stopp = True
  3.  
  4. Do Until stopp = False
  5. If stopp = False Then
  6. Exit Do
  7. End If
  8. DoEvents
  9.  
  10.  
  11. EventPause ("5")
  12. SendKeys ("message")
  13. EventPause ("1")
  14. SendKeys ("message1")
  15. EventPause ("1")
  16. SendKeys ("message2")
  17. EventPause ("1")
  18. SendKeys ("message3")
  19. EventPause ("1")
  20. SendKeys ("message4")
  21. EventPause ("1")
  22. SendKeys ("message5")
  23. EventPause ("1")
  24. SendKeys ("message6")
  25. EventPause ("1")
  26. SendKeys ("message7")
  27. EventPause ("1")
  28. SendKeys ("message8")
  29. EventPause ("1")
  30. SendKeys ("message9")
  31. EventPause ("1")
  32. SendKeys ("message10")
  33. EventPause ("1")
  34. SendKeys ("message11")
  35. EventPause ("1")
  36. DoEvents
  37. Loop
  38.  
  39. End Sub
  40.  
  41. 'Cancel button
  42. Private Sub Command1_Click()
  43. stopp = False
  44. End Sub

However, this only stops the loop once it is completed and back to the start. Maybe I am using DoEvents wrong? Could somone please modify my code so the split second the "stop" button is pushed the loop stops?

Again: it stops fine, but only once the loop is completed. I want to stop mid-loop the second the stop button is pushed.

Thanks!