Start\Stop watch

I have five labels and one button. I need to detect when the button is clicked the first time and the first label shows 00:00 (but time is running, however) and when the button is clicked a second time, label two show HOW much time has passed since the first click. (ex: 02:00). Then when they click again, the third label shows how much time has passed since the second click.(ex: 00:15) 3rd label is when a third click is started, but adds from the value of the 2nd click. Once we get that total, we wait until we get a forth click. The fourth click is the difference from label 3. But at the same time label 5 takes the beginning total of time of the procedure.

Short desc:
First click:
Label1: 00:00
Second click:
Label2: 02:00
Third click:
Label3: 00:15
Forth click:
Label4: 03:00
Label5: 05:15

I'm found this much, but need help substracting, adding and totaling:
var:



label1.caption := '00:00'
GetLocalTime(StartWatch2);
  Label2.caption := IntToStr(StartWatch2.whour)+':'+IntToStr(StartWatch2.wMinute)+':'+IntToStr(StartWatch2.wSecond);\\can't figure out how to substract time here...

An example would be helpful...(my expert level with delphi is slightly above beginner).
JPersingerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
rwilson032697Connect With a Mentor Commented:
You can do this:

Var
  StartTime, EndTime : TDateTIme;

....
  StartTime := Now // First click
....
  EndTime := Now; // Second click

label2.caption := formatdatetime('hh:nn:ss', EndTime - StartTime);

Does this help?

Cheers,

Raymond.

0
 
JPersingerAuthor Commented:
Gees - you made it look easy...:) Thanks. works likes a champ.
0
 
rwilson032697Commented:
Your welcome :-)
0
All Courses

From novice to tech pro — start learning today.