Purpose 
Interrupts a currently running subroutine to process pending user input. 
Use DoEvents to develop applications that respond to user input while the application loops, and to monitor data or update values on the form. 
Syntax 
DoEvents (StartTime, EndTime) 
Example 
Sub Click () 
        Dim StartTime as integer 
        LastTime as integer 
        Dim IconNumber as integer 
         
        Randomize 
        StartTime = Timer 
         
        Do While (Timer < StartTime + 60) 
'run loop for 60 seconds 
                If Timer > LastTime + 1 Then 
'every second, run this code 
                IconNumber = Int ( (9 * Rnd) +1)         
'Generate 1 of 9 random icons 
                DisplayIcon(IconNumber) 
        End If 
        DoEvents '**Call DoEvents to process pending input** 
        Loop 
End Sub 
 |