Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting time from milliseconds to minutes/seconds 1

Status
Not open for further replies.

redaccess

MIS
Aug 2, 2001
110
US
I'm using the timer function to calculate how long it takes for a user to complete a form. Unforunately, the timer function uses milliseconds and I'm trying to figure out how to convert those milliseconds into minutes and seconds.
If anyone could describe to me how to do this or offer a better solution I'd appreciate it.
 
1000 millseconds = 1 second.

Dim tmrStart
Dim tmrEnd
Dim ElapsedTime
ElapsedTime = tmrEnd - tmrStart'Milliseconds
ElapsedTime = Elapsedtime/1000 ' Now we have Seconds
ElapsedTime = ElapsedTime / 60 'Now we have minutes.

Note, this was in sequence. To go directly to minutes:

ElapsedTime = ElapsedTime/60000
 
another method
this one sets a module level variable to the time when the form opens, then compares the time when you close the form to that variable and displays it in hours:minutes:seconds

Option Compare Database
Option Explicit
Dim Stime As Date

Private Sub Form_Close()
Dim Etime As Date
Etime = Now() - Stime
MsgBox "Elapsed time was " & Format(Etime, "hh:nn:ss")
End Sub

Private Sub Form_Load()
Stime = Now()
End Sub

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top