Yield execution so the operating system can process other events.


When using DoEvents make sure the same procedure cannot be executed multiple times before the first call returns; this can cause unpredictable results.

The DoEvents() function can be used in VBA only.


Wait during a long loop operation, pausing once every 1000 loops:

Dim i As Integer
For i = 1 To 15000 ' Start loop.
  If i Mod 1000 = 0 Then ' If loop has repeated 1000 times.
     DoEvents ' Yield to operating system.
  End If
' Other stuff happens here..
Next i

Wait for 3secs:

Dim WAIT As Double
WAIT = Timer

While Timer < WAIT + 3
    DoEvents  'do nothing

“Begin at the beginning, the King said, very gravely, and go on till you come to the end: then stop” ~ Lewis Carroll


.CancelEvent - Cancel an event.
For - Loop
OnClick, OnOpen - Events.

Copyright © 1999-2023
Some rights reserved