Results 1 to 2 of 2

Thread: Timer

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    18

    Post

    My question is related to the timers interval, what is the exact interval for 1 second, 1000 comes pretty close but it loose apporximately a second every 3 to 4 minutes, and I need it to be really exact, is there an interval that is exactly 1 second?

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    I noticed this a while back - timers aren't particularly accurate - in fact if you drag a window around the screen continuously a timer event won't occur until you drop it (at least in 16-bit VB4 it didn't - I don't know about now!)
    What I would do is set a timer event to happen every 100th of a second (Timer.Interval=10) and do something like this;

    Dim LastTime as Date
    LastTime=Now

    Sub Timer1.Timer
    If DateDiff("s",LastTime,Now)>=1 Then
    [do what you need to do each second]
    LastTime=Now
    Endif
    End Sub


    I haven't tested this code so I don't know if it works - basically every 100th of a second it checks to see if it's a second later than it looked last time

    Hope this helps.


    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width