DoEvents

Yield execution so the operating system can process other events.

Syntax
      DoEvents

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 may be used in VBA only.

Examples

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
Wend 

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

Related:

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


© Copyright SS64.com 1999-2013
Some rights reserved