Hello everybody. I used the following code to try the DoEvents function. On a form put Timer1 with Interval=1000 and Timer2 with Interval=5000:
If you launch the code, you'll see that i always equals 1. But it shouldn't be so, because of the DoEvents, which should allow the Timer2_Timer event to fire while another Timer2_Timer() Sub is being executed. Do you know why this is so? Thanks.Code:Dim t As Integer Private Sub Timer1_Timer() t=t+1 End Sub Private Sub Timer2_Timer() Static i as Integer i=i+1 Debug.Print i t=0 Do Until t=10 DoEvents Loop i=i-1 End Sub




Reply With Quote