Option Compare Database
Option Explicit
Private Declare Function Win32GetTickCounter Lib "Kernel32" _
Alias "GetTickCount" () As Long
Private CompTime As Long
Private Sub Form_Load()
CompTime = Win32GetTickCounter
End Sub
Private Sub Form_Timer()
Dim TickValue As Long
Dim Difference As Long
TickValue = Win32GetTickCounter
Difference = TickValue  CompTime
Dim ComputerHours As Long
Dim ComputerMinutes As Long
Dim ComputerSeconds As Long
Dim ApplicationHours, ApplicationMinutes, ApplicationSeconds As Long
ComputerHours = (TickValue \ 3596400) Mod 24
ComputerMinutes = (TickValue \ 59940) Mod 60
ComputerSeconds = (TickValue \ 999) Mod 60
ApplicationHours = (Difference \ 3596400) Mod 24
ApplicationMinutes = (Difference \ 59940) Mod 60
ApplicationSeconds = (Difference \ 999) Mod 60
txtAppTime = "This application has been ON for " & _
CStr(ApplicationHours) & " hours, " & _
CStr(ApplicationMinutes) & " minutes, and " & _
CStr(ApplicationSeconds) & " seconds"
txtCompTime = "This computer has been on for " & _
CStr(ComputerHours) & " hours, " & _
CStr(ComputerMinutes) & " mnutes, and " & _
CStr(ComputerSeconds) & " seconds"
End Sub
