Group: microsoft.public.word.vba.general
From: =?Utf-8?B?U3RldmVuTQ==?=
Date: Sunday, April 13, 2008 3:35 PM
Subject: Finding Minutes & Seconds When Using Timer

I’ve been using the Timer function to time my macros, but every now and then
I end up with a negative number when trying to calculate minutes and seconds.
For example:

Sub TestTimer()
Dim tTime As Single
Dim nMinutes As Long
Dim nSeconds As Long
tTime = Timer
nMinutes = CLng(tTime / 60)
nSeconds = CLng(tTime - (nMinutes * 60))
MsgBox "Timer = " & tTime & Chr(13) _
& nMinutes & " minutes and " & nSeconds & " seconds"
End Sub

One result which I’ve received was:
"Timer = 53818.06
897 minutes and –2 seconds"

897 minutes is 53820 seconds, just two more than what the Timer gave.

Why do I sometimes get a negative number?

Steven Craig Miller

Safety Articles | Usenet Groups | Usenet News | Bluegrass