To pause your app, you should remove the doevents statement, since it could allow any events to fire and run during the loop. Sleep does that as well.

But i think what you meant with pause is just to have a dealy to the code that follows.