Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to read system clock - to monitor time elapse in ms

7 views
Skip to first unread message

Chut Ngeow, Yee

unread,
Mar 16, 1998, 3:00:00 AM3/16/98
to

Dear All,

I like to monitor time elapse in ms. Can someone point me to the the right
api function, and how to interpret the result?

I wonder why the good old Quick basic function is not available in vb...

Thanks in advance.

Chut Ngeow Yee

Garth Oatley

unread,
Mar 17, 1998, 3:00:00 AM3/17/98
to

Hi,

You could use the following...

' API Declarations...
' Use VB Currency type instead of LARGE INTEGER type.

Private Declare Function QueryPerformanceCounter Lib "kernel32" _
(lpPerformanceCount As Currency) As Long
Private Declare Function QueryPerformanceFrequency Lib "kernel32" _
(lpFrequency As Currency) As Long

Private m_secFreq As Currency

Private Sub StartTimer(secStart As Currency)
If m_secFreq = 0 Then QueryPerformanceFrequency m_secFreq
QueryPerformanceCounter secStart
End Sub

Private Sub StopTimer(secStart As Currency, secTimer As Currency)
QueryPerformanceCounter secTimer
If m_secFreq = 0 Then
secTimer = 0 ' Cannot Handle Performace Timer
Else
secTimer = (secTimer - secStart) / m_secFreq
End If

End Sub

You can then call the function.

Private Sub Command1_Click()
Dim secStart As Currency
Dim secEnd As Currency

StartTimer secStart

' Do Stuff...

StopTimer secStart, secEnd

' Result Stored in secEnd

End Sub

Hope this helps...

Garth Oatley

Chut Ngeow, Yee <y...@ctsolution.com.my> wrote in article
<01bd5163$71e6b880$LocalHost@ngeow>...

Gofreddo

unread,
Mar 17, 1998, 3:00:00 AM3/17/98
to
or you could use Timer.


Garth Oatley wrote in message <01bd5190$6adcfd10$ae09d9c2@mnvqc>...

Gofreddo.vcf

André-Tascha Ham-Lammé

unread,
Mar 17, 1998, 3:00:00 AM3/17/98
to

>>Gofreddo wrote in message ...


>>or you could use Timer.


Only if you wanted a completely inaccurate span of time <g>. The Timer
control is notorious for being a bit on the "it's been around 200 or so ms
so let's fire the routine" side of things

Gofreddo

unread,
Mar 17, 1998, 3:00:00 AM3/17/98
to
Actually, I was referring to the Timer function, which returns the number (fraction) of seconds elapsed since midnight. I am sure it is not as reliable as the api, but I am also sure it is not nearly as unreliable as the control. The original person who wrote the request was only looking for a "replacement" for the QB function, which didn't give great accuracy either. I am not disagreeing that the timer is EXTREMELY unreliable though. Thanks for clearing that up. I would hate for someone to have gone away from this message thinking they should use the timer control.


André-Tascha Ham-Lammé wrote in message <6en6hs$o...@suriname.earthlink.net>...

Gofreddo.vcf
0 new messages