# Re: 请问VB里有函数可以取得系统当时的毫秒吗?

Posted by Hanting on September 10, 1999 at 10:51:41:

In Reply to: 请问VB里有函数可以取得系统当时的毫秒吗? posted by 大呆 on September 07, 1999 at 18:21:15:

以下是摘自CWW的WEBSITE，PLEASE TAKE A LOOK AT THERE，BY THE WAY ， AS
I CHECKED IT, I FOUND IT COULD GENERATE 1MS RATHER THAN 1US. BE IN
MIND.

更精确的计时

一般使用Timer物件，没有办法精确的算到微秒，(每秒目更新18.2次)，若要算到
微秒，则使用GetTickCount ，它传回Windows启动后到目前为止所经过的时间，
传回值以微秒为单位。

Private Declare Function GetTickCount Lib "kernel32" Alias _
"GetTickCount" () As Long

Private CanContinue as Boolean

Private Sub Command1_click()
Dim i as Long
Dim j as Long
i = GetTickCount()
CanContinue = True
Do While CanContinue
j = GetTickCount()
if j - i > 50 Then
Debug.Print "已过50微秒"
i = j
End If
DoEvents
Loop
End Sub

Private Sub Command2_Click()
CanContinue = False
End Sub

Follow Ups:

- Re: 请问VB里有函数可以取得系统当时的毫秒吗? 大呆 11:48:16 9/13/99 (0)