Coding Timernya <><><><><><><>
unit latihan2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Timer1: TTimer;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
awal, akhir : TDateTime;
lama : real;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Interval:=1;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
Slama : string;
begin
if Button1.Caption='Stop' then
begin
akhir := Time;
Edit2.Text:=TimeToStr(akhir);
lama := (akhir-awal)*100000;
Str(lama:12:2,Slama);
Edit3.Text:=Slama;
end
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Button1.Caption='Start' then
begin
awal := Time;
Edit1.Text:=TimeToStr(Time);
Button1.Caption:='Stop';
end
else if Button1.Caption='Stop' then
begin
Button1.Caption:='Selesai'
end
else
Application.Terminate;
end;
end.
Screen Shut Programnya :
unit latihan2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Timer1: TTimer;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
awal, akhir : TDateTime;
lama : real;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Interval:=1;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
Slama : string;
begin
if Button1.Caption='Stop' then
begin
akhir := Time;
Edit2.Text:=TimeToStr(akhir);
lama := (akhir-awal)*100000;
Str(lama:12:2,Slama);
Edit3.Text:=Slama;
end
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Button1.Caption='Start' then
begin
awal := Time;
Edit1.Text:=TimeToStr(Time);
Button1.Caption:='Stop';
end
else if Button1.Caption='Stop' then
begin
Button1.Caption:='Selesai'
end
else
Application.Terminate;
end;
end.
Screen Shut Programnya :
Tags
Delphi 7