Friday, November 22, 2013

Membuat Kalkulator Kubikasi Sederhana Dengan Delphi

Kalkulator sederhana untuk menghitung kubikasi / CBM,
dan meliputi converter yang berguna untuk skala kecil-kecilan.
untuk source code atau contohnya klik disini




unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    Panel1: TPanel;
    Edit6: TEdit;
    Edit7: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Panel2: TPanel;
    Label4: TLabel;
    Label5: TLabel;
    Edit8: TEdit;
    Edit9: TEdit;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    Label12: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Edit1KeyPress(Sender: TObject; var Key: Char);
    procedure Edit2KeyPress(Sender: TObject; var Key: Char);
    procedure Edit3KeyPress(Sender: TObject; var Key: Char);
    procedure Edit5KeyPress(Sender: TObject; var Key: Char);
    procedure Label1Click(Sender: TObject);
    procedure Edit6Change(Sender: TObject);
    procedure Edit6KeyPress(Sender: TObject; var Key: Char);
    procedure Edit7Change(Sender: TObject);
    procedure Edit7KeyPress(Sender: TObject; var Key: Char);
    procedure Edit8Change(Sender: TObject);
    procedure Edit9Change(Sender: TObject);
    procedure Edit9KeyPress(Sender: TObject; var Key: Char);
    procedure Edit8KeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);

   private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  p,l,t,q,y,m,hasil: extended;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
IF edit1.text='' THEN
Begin
MessageDlg('Panjang masih kosong',mtInformation,[mbOK],0);
edit1.setfocus;
END;

IF edit2.text='' THEN
Begin
MessageDlg('Lebar masih kosong',mtInformation,[mbOK],0);
edit2.setfocus;
END;

IF edit3.text='' THEN
Begin
MessageDlg('Tinggi masih kosong',mtInformation,[mbOK],0);
edit3.setfocus;
End;

IF edit5.text='' THEN
Begin
MessageDlg('Kuantity masih kosong',mtInformation,[mbOK],0);
edit5.setfocus;
End;

BEGIN
p:=strtofloat(edit1.text);
l:=strtofloat(edit2.text);
t:=strtofloat(edit3.text);
q:=strtofloat(edit5.text);

hasil:= p*l*t*q/1000000;
edit4.text:= floattostr(hasil);

end;
END;

procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end;


procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
IF key=chr(13)
then
begin edit2.SetFocus;
end;
end;

procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
IF key=chr(13)
then
begin edit3.SetFocus;
end;
end;

procedure TForm1.Edit3KeyPress(Sender: TObject; var Key: Char);
begin
IF key=chr(13)
then
begin edit5.SetFocus;
end;
end;

procedure TForm1.Edit5KeyPress(Sender: TObject; var Key: Char);
begin
IF key=chr(13)
then
begin Button1.SetFocus;
end;
end;

procedure TForm1.Label1Click(Sender: TObject);
begin
edit1.text:='';
edit2.text:='';
edit3.text:='';
edit4.text:='';
edit5.text:='';
edit6.text:='';
edit7.text:='';
edit8.text:='';
edit9.text:='';
end;



procedure TForm1.Edit6Change(Sender: TObject);
begin
IF edit6.text='' THEN
 Begin
 edit7.Text:='';

end;

y:=strtofloat(edit6.text);
m:=y*0.9144;
edit7.text:= floattostr(m);

end;


procedure TForm1.Edit6KeyPress(Sender: TObject; var Key: Char);
begin
IF key=chr(13)
then
begin edit7.SetFocus;
end;
end;




procedure TForm1.Edit7Change(Sender: TObject);
begin
IF edit7.text='' THEN
 Begin
 edit6.Text:='';

      end;

y:=strtofloat(edit7.text);
m:=y/0.9144;
edit6.text:= floattostr(m);

end;

procedure TForm1.Edit7KeyPress(Sender: TObject; var Key: Char);
begin
IF key=chr(13)
then
begin edit6.SetFocus;
end;
end;


procedure TForm1.Edit8Change(Sender: TObject);
begin
IF edit8.text='' THEN
 Begin
 edit9.Text:='';

end;

y:=strtofloat(edit8.text);
m:=y*2.54;
edit9.text:= floattostr(m);

end;


procedure TForm1.Edit8KeyPress(Sender: TObject; var Key: Char);
begin
IF key=chr(13)
then
begin edit9.SetFocus;
end;
end;

procedure TForm1.Edit9Change(Sender: TObject);
begin
IF edit9.text='' THEN
 Begin
 edit8.Text:='';

      end;

y:=strtofloat(edit9.text);
m:=y/2.54;
edit8.text:= floattostr(m);

end;



procedure TForm1.Edit9KeyPress(Sender: TObject; var Key: Char);
begin
IF key=chr(13)
then
begin edit8.SetFocus;
end;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
form1.Position := poDesktopCenter;
form1.BorderStyle := bssingle;
form1.BorderIcons := BorderIcons - [bimaximize] ;
end;

end.

No comments:

Post a Comment