新建From1(窗体),新建Command1(按钮CommandButton),代码:
Private Declare Function osQueryPerformanceCounter Lib "Kernel32" Alias "QueryPerformanceCounter" (lpPerformanceCount As Currency) As Long
Private Declare Function osQueryPerformanceFrequency Lib "Kernel32" Alias "QueryPerformanceFrequency" (lpFrequency As Currency) As Long
Public Function f_Timer() As Single
Dim freq As Currency, count As Currency
osQueryPerformanceFrequency freq
osQueryPerformanceCounter count
f_Timer = count / freq
End Function
Private Sub Command1_Click()
MsgBox f_Timer
End Sub
比如得到结果:7035.715