I'm trying to convert the Time$ string to a long representing the # of seconds so I can do comparisons of elapsed seconds easily. Essentially:
lSeconds = Hours * 3600 + Minutes *60 + Seconds
I have come up with a solution but it might not be the best solution. My solution is as follows:
How does this code look and is there a far better way to turn the Time$ to seconds? I am doing this in the 16 bit compiler if that matters.
------------------
Patrick White
[This message has been edited by Patrick White (edited June 22, 2001).]
lSeconds = Hours * 3600 + Minutes *60 + Seconds
I have come up with a solution but it might not be the best solution. My solution is as follows:
Code:
sTime = Time$ sSecs = Right$(sTime,2) ' Does Time$'s hours field always fill with a leading zero? if Len(sTime) = 8 then sHours = Left$(sTime,2) sMins = Mid$(sTime, 4,2) Else 'Hour is a single digit sHours = Left$(sTime,1) sMins = Mid$(sTime, 3,2) End If ' 48 is the ASCII for "0" (Zero) ' Convert the sSeconds, sMinutes and sHours to lSeconds lS = (CVByt(Left$(sSecs,1),1)-48)*10 + CVByt(Right$(sSecs,1),1)-48 lM = ((CVByt(Left$(sMins,1),1)-48)*10 + CVByt(Right$(sMins,1),1)-48)*60 lH = ((CVByt(Left$(sHours,1),1)-48)*10 + CVByt(Right$(sHours,1),1)-48)*3600 lTime(ub) = lS + lM + lH
------------------
Patrick White
[This message has been edited by Patrick White (edited June 22, 2001).]
Comment