
Accuracy of timers in VB?
Any suggestions about the accuracy of timers in VB? (using VB2)
In theory the following code should print a message every 60 secs.
In practice it prints a message once every 61-62 secs if I do
absolutely nothing else; if I keep Windows quite busy doing other
stuff
(nothing very compute-bound; just tapping away at an editor, or
checking
through fles via file manager) I get messages ever 65-90 seconds.
Does anyone know any way to get more accurate timings
(like maybe +-5 secs) out of VB?
Let me guess: use a timer, but when it times out sample system time
with Time or Time$. Do unpleasant messing to subtract starting time
from
latest value returned by Time.
-----------------------------
Sub Form_Load ()
rem m%, n% are Dimmed for form
m% = 0
n% = 0
Show
form1.Print Time$
End Sub
___________________________________
Sub Timer1_Timer ()
rem Timer1 has Interval of 1000
n% = n% + 1
If n% = 59 Then
n% = 0
form1.Print Time$
m% = m% + 1
If m% = 6 Then End
End If
End Sub
Yours,
Alan Campbell
Brighton, UK
<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>