depending on timer may effect the application, it reacts differently in different operating environments, i hope the code given below may help you
'code starts from here
Private Declare Sub Sleep lib "kernel32" (ByVal dwMilliseconds as long)
'Command Click
Dim lngLoopCntr as long
Dim lngMilliSecs as Long
lngLoopCntr=0 ' although it initializes to 0 , but it is a gud practise to initialize variable
lngMilliSecs = 10000 ' 10 Seconds
Do While True
Sleep 10
lngLoopCntr=lngLoopCntr + 10
if lngLoopCntr > lngMilliSecs then exit Do
Loop
Msgbox "Done"
'Code Ends :surprised
I need to create time intervals in the millisecond range (e.g. 30 ms), not the seconds range. These are necessary for real-time control of equipment.
The problem is that Windows takes a time-out every 55 milliseconds to do its mousekeeping, and all I/O must occur during the mouskeeping period.
When the real-world event which is supposed to start the interval occurs, Windows won't let the computer program know about it until the program's jiffy is over and Windows does the I/O during the mousekeeping period. So the timer starts late.
Then, after the interval ends, Windows won't let the command be sent to the real-world equipment until the program's jiffy ends and Windows does the I/O during the mousekeeping period. So the timed interval ends late.
The total elapsed time is 55 ms times a random number in the range [0..1), plus 55 ms times the next highest integer of the quotient of the desired interval divided by 55 ms. The random number term represents the time left in the 55 ms jiffy when the real-world event actually occurs, and the other term represents the actual time elapsed from the start of the timer to the output of the command to the real-world equipment.
So, no matter what interval I really need, I get a longer interval which is at least 55 ms long. The process is done wrong, and the desired result is not achieved.
The intervals I need are based on real-world constants, and cannot be changed to accommodate Windows.
Microsoft made computers totally useless for my application when it changed from MS-DOS to Windows.