Minggu, 23 Desember 2012
Selisih Tanggal
23.39
No comments
catatan :
buat fungsi tanggal sebagai berikut :
function SelisihTanggal(TglOld,TglNew: TDate): Integer;
begin
Result:= Trunc(TglNew - TglOld);
end;
letakkan source code ini pada even onclik tombol hitung
Edit1.Text:= IntToStr(SelisihTanggal(DateTimePicker1.Date, DateTimePicker2.Date));
letakkan source code ini pada even form create
DateTimePicker2.Date:= Now;
source code selengkapnya:
{ http://opxbit.web.id }
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
DateTimePicker1: TDateTimePicker;
DateTimePicker2: TDateTimePicker;
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function SelisihTanggal(TglOld,TglNew: TDate): Integer;
begin
Result:= Trunc(TglNew - TglOld);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text:= IntToStr(SelisihTanggal(DateTimePicker1.Date, DateTimePicker2.Date));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DateTimePicker2.Date:= Now;
end;
end.
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar