- Home >
- Delphi , fakti upy , Materi Kuliah , PBO >
- Menghitung Luas Persegi Panjang - Delphi
Posted by : Efdi
Minggu, 01 Desember 2013
unit luas_persegi_panjang;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
edtLebar: TEdit;
lbPanjang: TLabel;
lbLebar: TLabel;
edtPanjang: TEdit;
lbLuas: TLabel;
lbLKeliling: TLabel;
edtLuas: TEdit;
edtKeliling: TEdit;
btnHitung: TButton;
btnReset: TButton;
btnClose: TButton;
Label1: TLabel;
procedure btnCloseClick(Sender: TObject);
procedure btnResetClick(Sender: TObject);
procedure btnHitungClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnCloseClick(Sender: TObject);
begin
close;
end;
procedure TForm1.btnResetClick(Sender: TObject);
begin
edtPanjang.Text:='';
btnReset.Caption:='reset';
edtLebar.Text:='';
btnReset.Caption:='reset';
edtLuas.Text:='';
btnReset.Caption:='reset';
edtKeliling.Text:='';
btnReset.Caption:='reset';
end;
procedure TForm1.btnHitungClick(Sender: TObject);
Var
nPanjang : Integer;
nLebar : Integer;
nLuas : Integer ;
nKeliling : Integer ;
begin
nPanjang := StrToInt(edtPanjang.text);
nLebar := StrToInt(edtLebar.Text);
nLuas := nPanjang * nLebar;
nKeliling := (nPanjang + nLebar) *2;
edtLuas.text := IntToStr(nLuas);
edtKeliling.text := IntToStr(nKeliling);
end;
end.