- 帖子
- 22
- 主題
- 17
- 精華
- 0
- 積分
- 51
- 點名
- 0
- 作業系統
- wiindows
- 軟體版本
- Office 2010
- 閱讀權限
- 20
- 性別
- 男
- 來自
- 新北
- 註冊時間
- 2021-6-21
- 最後登錄
- 2022-1-4
|
一般使用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 |
|