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 can 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 © 1999-2024 SS64.com
Some rights reserved