Jump to content

Help ! for loop conver number to time


leme9
 Share

Recommended Posts

Func Sec2Time($nr_sec)
   $sec2time_hour = Int($nr_sec / 3600)
   $sec2time_min = Int(($nr_sec - $sec2time_hour * 3600) / 60)
   $sec2time_sec = $nr_sec - $sec2time_hour * 3600 - $sec2time_min * 60
   $sec2time_milli = $nr_sec - $sec2time_hour * 3600 - $sec2time_min * 60 
   Return StringFormat('%02d:%02d:%02d.%02d', $sec2time_hour, $sec2time_min, $sec2time_sec,$sec2time_milli)
EndFunc
For $i = 0 to 999999999
ToolTip(Sec2Time($i),0,0)
Sleep(100); change
Next

how to conver number in for loop to time type: "00:00:00.00" => HOUR:MIN:MSEC.MILLISECOND

1Msec = 100 millisecond

Edited by leme9
Link to comment
Share on other sites

Something like this?

Global $sDisplayTime = ""
Global $iTimer = TimerInit()
AdlibRegister("Sec2Time", 100)
While 1
    Sleep(50)
    ToolTip($sDisplayTime, 0, 0)
WEnd
Func Sec2Time()
    Local $iCounter = TimerDiff($iTimer) ; Milliseconds since start of script
    Local $iTempSec = $iCounter / 1000 ; Seconds since start of script
    $iHour = Int($iTempSec / 3600)
    $iMin = Int(($iTempSec - $iHour * 3600) / 60)
    $iSec = Int($iTempSec - $iHour * 3600 - $iMin * 60)
    $iMilli = Mod($iCounter, 1000)
    $sDisplayTime = StringFormat('%02d:%02d:%02d.%03d', $iHour, $iMin, $iSec, $iMilli)
EndFunc   ;==>Sec2Time

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

On 1/31/2016 at 12:11 AM, water said:

Something like this?

Global $sDisplayTime = ""
Global $iTimer = TimerInit()
AdlibRegister("Sec2Time", 100)
While 1
    Sleep(50)
    ToolTip($sDisplayTime, 0, 0)
WEnd
Func Sec2Time()
    Local $iCounter = TimerDiff($iTimer) ; Milliseconds since start of script
    Local $iTempSec = $iCounter / 1000 ; Seconds since start of script
    $iHour = Int($iTempSec / 3600)
    $iMin = Int(($iTempSec - $iHour * 3600) / 60)
    $iSec = Int($iTempSec - $iHour * 3600 - $iMin * 60)
    $iMilli = Mod($iCounter, 1000)
    $sDisplayTime = StringFormat('%02d:%02d:%02d.%03d', $iHour, $iMin, $iSec, $iMilli)
EndFunc   ;==>Sec2Time

 

$iMilli run 1 to 100 

Edited by leme9
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...