Synchronizing VB Timer with system time

Hi,

I'm making a countdown timer, and as you know, the VB timer control doesn't keep accurate time (in seconds). Is there anyway to get the timer in sync with the PC's system time?




Thank you for your time,

Ron


Comments

  • I can't remember now but there are several API functions that deal with time. So if you're familiar with this use this.





  • If the time count down value sought is a known value (say, 5 seconds), it would seem to me that you could project from the then current System Time(ST), the value of a future System Time (VFST) desired, then have the Timer check: If VFST >= ST then .


  • Just pass the number of seconds you want to delay. Anything greater than 60 will require a check against the minutes. I can expand it to check the minutes if you are interested.


    Sub SecondsDelay(ByVal NumSeconds As Integer)


    StartTime = CInt(Format(Now, "s"))

    Do Until CInt(Format(Now, "s")) = StartTime + NumSeconds

    DoEvents

    Loop


    End Sub




Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories