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
Printable View
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
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.
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.