GetTotalTime Function (1 Viewer)

Status
Not open for further replies.

Dreamweaver

Well-known member
Local time
Today, 04:28
Joined
Nov 28, 2005
Messages
2,466
Well managed to solve the problems I was having in that it seems some values where being converted to strings so when I got to point Dm and tried adding both mins together it just combined them took me a while to notice the double quotes :eek::eek:

I'm sure there's a simpler way to do this if so please let me know

This function does not round up the final mins and it needs a lot of cleaning up plus there may be the possibility of an error at "Z = InStr(S, ".")" should the number be a whole number.

Hope it helps somebody.

Code:
Function GetTotalTime(T As String, N As Long) As String
Dim hourss As Integer, mins As Integer, secs As Integer, timeinsecs As Integer
'Written By Geoff From Kent Telephones
mins = Val(Mid$(T, 1, InStr(T, ":")))
secs = Val(Mid$(T, InStr(T, ":") + 1))

timeinsecs = mins * 60 + secs
timeinsecs = timeinsecs * N
hourss = Int(timeinsecs / 3600)
mins = timeinsecs - (hourss * 3600)
mins = Int(mins / 60)
secs = timeinsecs - (hourss * 3600) - (mins * 60)
GetTotalTime = hourss & ":" & mins '& ":" & secs


End Function
 
Last edited by a moderator:
Status
Not open for further replies.

Users who are viewing this thread

Top Bottom