Board index » delphi » time display in memo

time display in memo

Hi there,

I have a memo in my Stop watch application to save elapsed times. I
have two problems:
1. the second line is always being skip for some reason i.e it will
write on the first line then skip second line and then write fine for
the remaining lines

2. I can't get the time saved in HH:MM:SS:TT where tt is in
milliseconds e.g 00:00:02:233

This is part of the code in my procedure
TStopwatchForm.BitBtn3Click(Sender: TObject);

var
   TimeInMemo: String;
begin
     DecodeTime(Elapsed, Hour, Min, Sec, MSec);    
     Format('%.2d:%.2d:%.2d:%.2d', [Hour,Min,Sec,MSec]);
     TimeInMemo := DateTimetoStr(Elapsed);
     Memo1.Lines.Append(TimeInMemo);
     Format('%.2d:%.2d:%.2d:%.2d', [Hour,Min,Sec,MSec]);

thanks
Roy.

 

Re:time display in memo


Hi Roy,

Quote
>      TimeInMemo := DateTimetoStr(Elapsed);
>      Memo1.Lines.Append(TimeInMemo);

use Memo1.Lines.Add(TimeInMemo) instead.

Why do you write twice this?

Quote
>      Format('%.2d:%.2d:%.2d:%.2d', [Hour,Min,Sec,MSec]);

Rudy
============================================================
Quote
Roy wrote:

> Hi there,

> I have a memo in my Stop watch application to save elapsed times. I
> have two problems:
> 1. the second line is always being skip for some reason i.e it will
> write on the first line then skip second line and then write fine for
> the remaining lines

> 2. I can't get the time saved in HH:MM:SS:TT where tt is in
> milliseconds e.g 00:00:02:233

> This is part of the code in my procedure
> TStopwatchForm.BitBtn3Click(Sender: TObject);

> var
>    TimeInMemo: String;
> begin
>      DecodeTime(Elapsed, Hour, Min, Sec, MSec);
>      Format('%.2d:%.2d:%.2d:%.2d', [Hour,Min,Sec,MSec]);
>      TimeInMemo := DateTimetoStr(Elapsed);
>      Memo1.Lines.Append(TimeInMemo);
>      Format('%.2d:%.2d:%.2d:%.2d', [Hour,Min,Sec,MSec]);

> thanks
> Roy.

Other Threads