Results 1 to 3 of 3

Thread: Timers

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    Wales
    Posts
    12

    Post

    I have made a simple timer using interval=100 etc

    but it seems to work at differnt speeds on faster or slower computers.

    Is it possible to get vb to copy the windows clock.

    Or is there another way.

    Thanx a lot Michael Baynham

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    You can use GetTickCount from the API.

    -
    'In module
    Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long

    'The 'Timer'
    Dim Temp as Long
    Dim Interval as Long
    Dim Enabled as Boolean

    Interval = 100
    Enabled = true

    While Enabled
    If Temp + Interval < GetTickCount Then
    Temp = GetTickCount

    'Code here
    Endif
    DoEvents
    Wend
    -

    ------------------
    [email protected]
    ...
    Every program can be reduced to one instruction which doesn't work.


  3. #3
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    I would say that timers interval is not dependant on a computer speed. But if time needed to execute codes inside timer (wich ir related to copmuter speed) become longer then timer's interval, then APP starts skipping Timer events. That especialy noticible if drawing is involved.

    I ussualy messure codes execution time inside Timer events and if it comes longer the Timer Interval I make the adjustment to Interval.


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