I know how to create a timer using the timer control, but don't know how to get it into the proper format. So what I'm saying is that I don't want the time displayed to be 126 seconds, but 2 minutes and 6 seconds. Any (easy) way to do this? Any help appreciated.
How to create a timer in Visual Basic 6?
i converted this from my C# code. Since i dont have visual basic 6 anymore, i just whiped this up from memory. Sorry if it doesnt compile directly. Use the visual basic 6 mod function to get the remander of seconds from seconds / 60
example:
iSecondsRemaining = iSeconds mod 60
Function ConvertTime(iSec as Integer) as String
'convert the time to 00:00 format
iMinutes as integer = 0
iSeconds as integer = iSec
sSeconds as string
'calculate
iSeconds = iSec mod 60 '(use the mod function)
iMinutes = iSec /60
'format
sSeconds = str$(iSeconds)
if (len(sSeconds) = 1) then sSeconds = "0" %26amp; sSeconds
Function = Str$(iMinutes) %26amp; ":" %26amp; sSeconds
end function
Reply:Public Function SetTimeFormat(ByVal TimeValue As Double)
On Error GoTo errorhandler
seconds = Fix(TimeValue)
mins = Fix(TimeValue / 60)
secs = TimeValue - (mins * 60)
If secs %26lt; 10 Then secs = "0" %26amp; secs
SetTimeFormat = mins %26amp; ":" %26amp; secs
Exit Function
errorhandler:
SetTimeFormat = "0:00"
End Function
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment