Set a Timer control to 5000ms. Declare a Boolean value that will remain in scope when the Timer event fires. Make the Timer's Timer event change the both Boolean to True and the Timer.Enabled property to False. Right in front of your Do loop, set the Boolean to False and enable the Timer. In your Do loop, check the Boolean value after your DoEvents. If the Boolean is True, Exit Do.
Oh i think i couldn't explain...
That's what i am doing now exactly. But it refuses to work in runtime.
when i debug step by step (F8), it works great. It returns a timeout. But if i do not debug, it does not response with a timeout. When i pause and begin step by step execution with F8 then it realizes that timeout is over and responses with a timeout.
But again thanks for your posts. But i'm asking you for another suggestion.
I've never been a real fan of using Date and Time functions with respect to timing issues. Since in this case, it seems that you want to enter into DoEvents loop for 5 seconds, I would control the timing using the GetTickCount API, and my sub would look something like the following:
In the Declarations section of the form, declare the following API
Private Declare Function GetTickCount Lib "kernel32" () As Long
and the sub
Private Sub DoEventsLoop (ByVal NumSeconds as Long)
Dim StartTime As Long
Dim DoLoop As Boolean
Dim TimeDiff As Long
Dim EndCount as Long
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.