Option Explicit
Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpCount As Currency) As Long
Private Tick_Count As Currency
Private Start_Time As Currency
Private End_Time As Currency
Private Delta_Time As Currency
Private Str As String
Private Seconds As Long
Private Function Modulus(ByVal Value1 As Double, ByVal Value2 As Double) As Double
'Similar to Value1 Mod Value2 only you can do bigger values
'than Mod in this function.
Modulus = Value1 - (Int(Value1 / Value2) * Value2)
End Function
Private Sub Form_Activate()
AutoRedraw = True
ScaleMode = 3
QueryPerformanceFrequency Tick_Count
QueryPerformanceCounter Start_Time
Dim Sec1 As Long, Sec10 As Long, Sec100 As Long
Dim Sec1000 As Long, Sec10000 As Long
Do
DoEvents
Delta_Time = (End_Time - Start_Time) / Tick_Count
If Modulus(Delta_Time, 1) Then Sec1 = Sec1 + 1
If Modulus(Delta_Time, 0.1) Then Sec10 = Sec10 + 1
If Modulus(Delta_Time, 0.01) Then Sec100 = Sec100 + 1
If Modulus(Delta_Time, 0.001) Then Sec1000 = Sec1000 + 1
If Modulus(Delta_Time, 0.0001) Then Sec10000 = Sec10000 + 1
lblsecs.Caption = CStr(Sec1)
lbl10.Caption = CStr(Sec10)
lbl100.Caption = CStr(Sec100)
lbl1000.Caption = CStr(Sec1000)
lbl10000.Caption = CStr(Sec10000)
QueryPerformanceCounter End_Time
Loop
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unload Me
End
End Sub