• elapsedTime function in LSTimer rounds hour and minute portions

    By Jim Romaine 2 decades ago

    While I had discovered this issue in the 1.0 release, I noticed that it is still in 1.5BETA. The function elapsedTime (shown below), appears to rounding the hours and minutes portions.



    Original code:

    elapsedTime = Format$(et / 3600000, "00") & ":" & _

    Format$((et/ 60000) Mod 60, &quot;00&quot;) &amp; &quot;:&quot; &amp; _<br/>
    Format$((et/ 1000) Mod 60, &quot;00&quot;)<br/>
    



    Suggested revision:

    elapsedTime = Format$(Fix( et / 3600000) , "00") & ":" & _

    Format$( Fix( et/ 60000)    , &quot;00&quot;) &amp; &quot;:&quot; &amp; _<br/>
    Format$((et/ 1000) Mod 60, &quot;00&quot;)<br/>
    



    to illustrate the issue I created a button with the following code:



    Dim et As Double

    Dim elapsedTime  As String<br/>
    Dim myVer As String<br/>
    <br/>
    

    ' et = elapsedMilliseconds(stopNow)

    et = Cdbl( Inputbox(&quot;Enter milliseconds to recalc:&quot;, &quot;Millisecond conversion&quot;) )<br/>
    elapsedTime = Format$(et / 3600000, &quot;00&quot;) &amp; &quot;:&quot; &amp; _<br/>
    Format$((et/ 60000) Mod 60, &quot;00&quot;) &amp; &quot;:&quot; &amp; _<br/>
    Format$((et/ 1000) Mod 60, &quot;00&quot;)<br/>
    <br/>
    elapsedTime2 = Format$(Fix( et / 3600000) , &quot;00&quot;) &amp; &quot;:&quot; &amp; _<br/>
    Format$( Fix( et/ 60000)    , &quot;00&quot;) &amp; &quot;:&quot; &amp; _<br/>
    Format$((et/ 1000) Mod 60, &quot;00&quot;)<br/>
    <br/>
    <br/>
    Msgbox &quot;Millisecs: &quot; &amp; et &amp; Chr$(10) &amp; _<br/>
    &quot;Orig conver: &quot; &amp; elapsedTime &amp; Chr$(10) &amp; _<br/>
    &quot;Suggested version: &quot; &amp; elapsedTime2<br/>
    





    Enter in 1893000 milliseconds.


    • Jim