Lagi malas nulis panjang lebar ni tak copiin aja source code nya ya :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
THITUNG = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Button1: TButton;
Image1: TImage;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
procedure bersih;
{ Private declarations }
public
{ Public declarations }
end;
var
HITUNG: THITUNG;
implementation
{$R *.dfm}
Var p,l,t,vol,luas : integer; // tempatkan variabel di atas procedur
procedure THITUNG.Button1Click(Sender: TObject);
begin
//konversi dari string ke integer
P := StrToInt(Edit1.text);
L := StrToInt(Edit2.text);
T := StrToInt(Edit3.text);
Vol := P*L*T ;
Luas := (2*P*T)+(2*P*L)+(2*T*L);
//konversi dari integer ke string
Edit4.Text := IntToStr(Vol);
Edit5.Text := IntToStr(Luas);
end;
procedure THITUNG.bersih;
begin
edit1.text :='';
edit2.Text :='';
edit3.Text :='';
edit4.text :='';
edit5.Text :='';
end;
procedure THITUNG.FormActivate(Sender: TObject);
begin
bersih;
end;
procedure THITUNG.Button2Click(Sender: TObject);
begin
CLOSE;
end;
end.
Tidak ada komentar:
Posting Komentar