Ver Mensaje Individual
  #10  
Antiguo 12-11-2003
YolandaM YolandaM is offline
Miembro
 
Registrado: jul 2003
Posts: 38
Reputación: 0
YolandaM Va por buen camino
hola otra vez CFPA86.
Mira este código me funciona bien.

//------------------------------------------------------------------//

unit sumahoras;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Mask, RzEdit, RzSpnEdt,dateutils;

type
TForm3 = class(TForm)
edit1: TRzSpinEdit;
edit2: TRzSpinEdit;
sumar: TBitBtn;
restar: TBitBtn;
Label3: TLabel;
Label4: TLabel;
Edit3: TEdit;
BitBtn1: TBitBtn;
Edit4: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure BitBtn1Click(Sender: TObject);
procedure sumarClick(Sender: TObject);
procedure restarClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Edit4Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form3: TForm3;

implementation
var totalh,TotalM,total,resta,totalm2: Ttime;


{$R *.dfm}

procedure TForm3.BitBtn1Click(Sender: TObject);
begin
close;
end;

procedure TForm3.sumarClick(Sender: TObject);
var Hour, Min, Sec, MSec: Word;
var hour2, min2,sec2,msec2: word;
begin
{ ---------------------------------------------------------------------}

Totalh:=totalh+Edit1.Value/24 ;
Totalm:=totalm+Edit2.Value/1440 ;
{ --------------------------------------}
total:=total + edit1.Value/24;
totalm2:=totalm2 + edit2.Value/1440;

decodetime(resta - total-totalm2, hour2,min2,sec2,msec2);
edit4.Text:=inttostr(hour2 + trunc(resta - total )* 24 ) +':'+IntToStr(min2);
{ -----------------------------------------}
DecodeTime(totalh+totalm, Hour, Min, Sec, MSec);
Edit3.Text:=IntToStr(hour + trunc(totalh+totalm) * 24) +':'+IntToStr(min);
Edit1.Value:=0;
Edit2.Value:=0;


{ -------------------------------------------------------------------}
end;
procedure TForm3.restarClick(Sender: TObject);
var Hour, Min, Sec, MSec: Word;
var hour2, min2,sec2,msec2: word;
begin
totalh:=totalh-Edit1.Value/24;
totalm:=totalm-Edit2.Value/1440;
total:=total - edit1.Value/24;
totalm2:=totalm2 -edit2.Value/1440;

decodetime(resta - total-totalm2, hour2,min2,sec2,msec2);
edit4.Text:=inttostr(hour2 + trunc(resta - total )* 24 ) +':'+IntToStr(min2) ;
DecodeTime(totalh+totalm, Hour, Min, Sec, MSec);


edit3.Text:=IntToStr(hour+trunc(totalh+totalm)*24)+':'+IntToStr(min);
edit1.Value:=0;
edit2.Value:=0;
End;

procedure TForm3.FormActivate(Sender: TObject);
begin
edit4.Text:='';
EDIT3.Text:='';
totalh:= 0;
totalm:= 0;
resta:= 64 / 24;
total:=0;
totalm2:=0;
end;

procedure TForm3.Edit4Change(Sender: TObject);
begin
if edit4.Text= '64:0' then restar.Enabled:=false else restar.enabled:=true;
if edit4.Text='0:0' then sumar.Enabled:=false else sumar.enabled:=true;
end;

initialization
totalh:= 0;
totalm:= 0;
resta:= 64 / 24;

end.

Gracias a tu interes y al foro en general.
YOLANDAM
Responder Con Cita