Mega Code Archive

 
Categories / Delphi / Forms
 

Converting a integer containing millisecs to a nice formated string

Title: Converting a integer containing millisecs to a nice formated string. Question: Converting a integer containing millisecs to a nice formated string. Answer: { This routine formats an integer representing milliseconds into a nice formated string: HH:MM:SS:Ms I use it in an audio application. E.J.Molendijk } function MSecToStr(MSec: Integer): string; begin Result := FormatFloat('00',MSec mod 1000 div 10); // msec MSec := MSec div 1000; Result := FormatFloat('00',MSec mod 60) + ':' + Result; // sec MSec := MSec div 60; Result := FormatFloat('00',MSec mod 60) + ':' + Result; // min MSec := MSec div 60; Result := IntToStr(MSec mod 60) + ':' + Result; // hour end;