Page 1 of 1
Posted: Wed Nov 20, 2002 9:11 am
by BackupUser
Restored from previous forum. Originally posted by cor.
What is the fastest way to count the total time e.g.
These values are in a string array.
Suggestions are welcome
00:01:25
01:03:56
05:45:20
Using Windows 98 SE
Registered PB version : 3.40 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Posted: Wed Nov 20, 2002 9:49 am
by BackupUser
Restored from previous forum. Originally posted by TheBeck.
Only problem is it doesn't retain the leading zero. What should be "06:01:01" is "6:1:1". I hope this helps.
Update: fixed no leading zero problem. I don't know if this is the fastest thou. I just saw a puzzle and had to solve it.
Code: Select all
Dim TimeList.s(3)
TimeList(1)="00:01:25"
TimeList(2)="01:03:56"
TimeList(3)="05:45:20"
TimeListSize = 3
TimeTotal = 0
OpenConsole()
For a = 1 To TimeListSize
TimeTotal = TimeTotal + ((Val(Mid(TimeList(a),1,2)) * 60) * 60) + (Val(Mid(TimeList(a),4,2)) * 60) + Val(Mid(TimeList(a),7,2))
Next a
TotalHRS = 0
Repeat
If TimeTotal >= 3600
TimeTotal = TimeTotal - 3600
TotalHRS = TotalHRS + 1
EndIf
Until TimeTotal = 60
TimeTotal = TimeTotal - 60
TotalMIN = TotalMIN + 1
EndIf
Until TimeTotal < 60
TotalSEC = TimeTotal
HRS.s = Str(TotalHRS)
MIN.s = Str(TotalMIN)
SEC.s = Str(TotalSEC)
If Len(HRS) = 1 : HRS = "0" + HRS : EndIf
If Len(MIN) = 1 : MIN = "0" + MIN : EndIf
If Len(SEC) = 1 : SEC = "0" + SEC : EndIf
PrintN(HRS + ":" + MIN + ":" + SEC)
Input()
end
Posted: Wed Nov 20, 2002 11:35 am
by BackupUser
Restored from previous forum. Originally posted by cor.
Thanks,
Works great
Using Windows 98 SE
Registered PB version : 3.40 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Posted: Wed Nov 20, 2002 10:14 pm
by BackupUser
Restored from previous forum. Originally posted by fred.
This one is a bit shorter
Code: Select all
#TimeMask = "%hh:%ii:%ss"
Debug FormatDate(#TimeMask, ParseDate(#TimeMask, "00:01:25")+ParseDate(#TimeMask, "01:03:56")+ParseDate(#TimeMask, "05:45:20"))
Fred - AlphaSND
Posted: Wed Nov 20, 2002 11:03 pm
by BackupUser
Restored from previous forum. Originally posted by cor.
Thanks Fred,
Thats indeed not a bit but a byte faster
Using Windows 98 SE
Registered PB version : 3.40 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com