Private Sub timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timer1.Tick
Dim CurTickValue As System.Int32 = Environment.TickCount
Dim Difference As System.Int32 = CurTickValue - CompTime
Dim ComputerHours As System.Int32
Dim ComputerMinutes As System.Int32
Dim ComputerSeconds As System.Int32
Dim ApplicationHours As System.Int32
Dim ApplicationMinutes As System.Int32
Dim ApplicationSeconds As System.Int32
ComputerHours = (CurTickValue / (3600 * 999)) Mod 24
ComputerMinutes = (CurTickValue / (60 * 999)) Mod 60
ComputerSeconds = (CurTickValue / 999) Mod 60
ApplicationHours = (Difference / (3600 * 999)) Mod 24
ApplicationMinutes = (Difference / (60 * 999)) Mod 60
ApplicationSeconds = (Difference / 999) Mod 60
label1.Text = String.Format("This computer has been ON for {0} hours, {1} minutes {2} seconds", _
CStr(ComputerHours), _
CStr(ComputerMinutes), _
CStr(ComputerSeconds))
label2.Text = String.Format("This application has been running for {0} hours, {1} minutes {2} seconds", _
CStr(ApplicationHours), _
CStr(ApplicationMinutes), _
CStr(ApplicationSeconds))
End Sub
|