CARA MEMBUAT APLIKASI KALKULATOR DENGAND DELPHI 7


CARA MEMBUAT APLIKASI KALKULATOR DENGAND DELPHI 7

BUAT FORM SEPERI DI BAWAH INI

CREATED BY A.Z.I.Z._T.E.K.N.I.K.I.N.F.O.R.M.A.T.I.K.A.

GB.1 A.Z.I.Z.

T.E.K.N.I.K.I.N.F.O.R.M.T.I.K.A.

 

MASUKAN SOURCE KODE DI BAWAH INI.

unit Unit1;

 

interface

 

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls;

 

type

TForm1 = class(TForm)

ButtonMr: TButton;

ButtonSin: TButton;

Button7: TButton;

Button4: TButton;

Button1: TButton;

Button0: TButton;

ButtonPoint: TButton;

ButtonNot: TButton;

ButtonResult: TButton;

Button2: TButton;

ButtonM: TButton;

ButtonCos: TButton;

Button8: TButton;

Button5: TButton;

ButtonPhi: TButton;

ButtonTan: TButton;

Button9: TButton;

Button6: TButton;

Button3: TButton;

ButtonPlus: TButton;

ButtonFak: TButton;

ButtonLn: TButton;

ButtonKuadrat: TButton;

ButtonKali: TButton;

ButtonOff: TButton;

ButtonLog: TButton;

ButtonAkar: TButton;

ButtonPangkat: TButton;

ButtonDiv: TButton;

ButtonOn: TButton;

ButtonPer: TButton;

ButtonMod: TButton;

ButtonMin: TButton;

ButtonBagi: TButton;

RbDEG: TRadioButton;

RbRAD: TRadioButton;

RbGRADS: TRadioButton;

Memo1: TMemo;

procedure FormCreate(Sender: TObject);

procedure ButtonOnClick(Sender: TObject);

procedure ButtonOffClick(Sender: TObject);

procedure Button0Click(Sender: TObject);

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure Button3Click(Sender: TObject);

procedure Button4Click(Sender: TObject);

procedure Button5Click(Sender: TObject);

procedure Button6Click(Sender: TObject);

procedure Button7Click(Sender: TObject);

procedure Button8Click(Sender: TObject);

procedure Button9Click(Sender: TObject);

procedure ButtonPlusClick(Sender: TObject);

procedure ButtonMinClick(Sender: TObject);

procedure ButtonKaliClick(Sender: TObject);

procedure ButtonBagiClick(Sender: TObject);

procedure ButtonModClick(Sender: TObject);

procedure ButtonDivClick(Sender: TObject);

procedure ButtonResultClick(Sender: TObject);

procedure ButtonKuadratClick(Sender: TObject);

procedure ButtonPointClick(Sender: TObject);

procedure ButtonNotClick(Sender: TObject);

procedure ButtonAkarClick(Sender: TObject);

procedure ButtonPangkatClick(Sender: TObject);

procedure ButtonLnClick(Sender: TObject);

procedure ButtonLogClick(Sender: TObject);

procedure ButtonPerClick(Sender: TObject);

procedure ButtonFakClick(Sender: TObject);

procedure ButtonPhiClick(Sender: TObject);

procedure ButtonSinClick(Sender: TObject);

procedure ButtonCosClick(Sender: TObject);

procedure ButtonTanClick(Sender: TObject);

procedure ButtonMClick(Sender: TObject);

procedure ButtonMrClick(Sender: TObject);

private

{ Private declarations }

public

{ Public declarations }

end;

 

var

Form1: TForm1;

 

MemAngka,MemLogic,MemOperator,MemSimpan:string;

implementation

uses math;

{$R *.dfm}

 

procedure TForm1.FormCreate(Sender: TObject);

begin

memo1.Clear;{mengosongkan caption / lines dari memo1}

 

{menonaktifkan ketiga radiobutton}

RbDEG.Enabled:=false;

RbRAD.Enabled:=false;

RbGRADS.Enabled:=false;

 

end;

 

procedure TForm1.ButtonOnClick(Sender: TObject);

begin

{setting ketika tombol on ditekan}

Memo1.Text:=’0′;

{membuat layar kalkulator berisi angka 0}

MemLogic:=’0′;

{merubah nilai variable MemLogic menjadi 0}

MemOperator :=”;

{mengosongkan nilai variable MemOperator}

MemAngka :=’0′;

{merubah nilai variable MemAngka menjadi 0}

 

{mengaktifkan kembali ketiga radiobutton}

RbDEG.Enabled:=true;

RbRAD.Enabled:=true;

RbGRADS.Enabled:=true;

 

RbDEG.Checked:=true; {mengecek radiobutton RbDeg}

 

end;

 

procedure TForm1.ButtonOffClick(Sender: TObject);

begin

memo1.clear; {mengosongkan tampilan layar calculator}

MemLogic:=”;

MemSimpan :=’0′;

 

{menonaktifkan ketiga radiobutton}

RbDEG.Checked  :=false;

RbRAD.Checked  :=false;

RbGRADS.Checked:=false;

 

end;

 

procedure TForm1.Button0Click(Sender: TObject);

begin

if memo1.text<>” then

if MemLogic=’0′ then

begin

if MemOperator<>” then memo1.Text:=’0′ else

if memo1.text=’0′ then memo1.text:=’0′ else

begin

memo1.Text:=memo1.Text+’0′;

MemLogic:=’1′;

end;

end

else

memo1.Text:=memo1.Text+’0′;

 

end;

 

procedure TForm1.Button1Click(Sender: TObject);

begin

if memo1.text<>” then

if MemLogic=’0′ then

begin

MemLogic:=’1′;

if MemOperator<>” then memo1.Text:=’1′ else

memo1.text:=’1′;

end

else

memo1.Text:=memo1.Text+’1′;

 

end;

 

procedure TForm1.Button2Click(Sender: TObject);

begin

if memo1.text<>” then

if MemLogic=’0′ then

begin

MemLogic:=’1′;

if MemOperator<>” then memo1.Text:=’2′ else

memo1.text:=’2′;

end

else

memo1.Text:=memo1.Text+’2′;

 

end;

 

procedure TForm1.Button3Click(Sender: TObject);

begin

if memo1.text<>” then

if MemLogic=’0′ then

begin

MemLogic:=’1′;

if MemOperator<>” then memo1.Text:=’3′ else

memo1.text:=’3′;

end

else

memo1.Text:=memo1.Text+’3′;

 

end;

 

procedure TForm1.Button4Click(Sender: TObject);

begin

if memo1.text<>” then

if MemLogic=’0′ then

begin

MemLogic:=’1′;

if MemOperator<>” then memo1.Text:=’4′ else

memo1.text:=’4′;

end

else

memo1.Text:=memo1.Text+’4′;

 

end;

 

procedure TForm1.Button5Click(Sender: TObject);

begin

if memo1.text<>” then

if MemLogic=’0′ then

begin

MemLogic:=’1′;

if MemOperator<>” then memo1.Text:=’5′ else

memo1.text:=’5′;

end

else

memo1.Text:=memo1.Text+’5′;

 

end;

 

procedure TForm1.Button6Click(Sender: TObject);

begin

if memo1.text<>” then

if MemLogic=’0′ then

begin

MemLogic:=’1′;

if MemOperator<>” then memo1.Text:=’6′ else

memo1.text:=’6′ ;

end

else

memo1.Text:=memo1.Text+’6′;

 

end;

 

procedure TForm1.Button7Click(Sender: TObject);

begin

if memo1.text<>” then

if MemLogic=’0′ then

begin

MemLogic:=’1′;

if MemOperator<>” then memo1.Text:=’7′ else

memo1.text:=’7′ ;

end

else

memo1.Text:=memo1.Text+’7′;

 

end;

 

procedure TForm1.Button8Click(Sender: TObject);

begin

if memo1.text<>” then

if MemLogic=’0′ then

begin

MemLogic:=’1′;

if MemOperator<>” then memo1.Text:=’8′ else

memo1.text:=’8′;

end

else

memo1.Text:=memo1.Text+’8′;

 

end;

 

procedure TForm1.Button9Click(Sender: TObject);

begin

if memo1.text<>” then

if MemLogic=’0′ then

begin

MemLogic:=’1′;

if MemOperator<>” then memo1.Text:=’9′ else

memo1.text:=’9′;

end

else

memo1.Text:=memo1.Text+’9′;

 

end;

 

procedure TForm1.ButtonPlusClick(Sender: TObject);

begin

if (memo1.text<>”) then

if MemLogic=’0′ then MemOperator:=’+’ else

if (MemOperator=”)  then

begin

MemOperator:=’+';

MemLogic:=’0′;

MemAngka:=memo1.Text;

end

else

begin

if MemOperator=’+’ then memo1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(memo1.Text));

if MemOperator=’-‘ then memo1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(memo1.Text));

if MemOperator=’x’ then memo1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(memo1.Text));

if MemOperator=’/’ then memo1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(memo1.Text));

if MemOperator=’mod’ then memo1.Text:=inttostr(strtoint(MemAngka) mod strtoint(memo1.Text));

if MemOperator=’div’ then memo1.Text:=inttostr(strtoint(MemAngka)div strtoint(memo1.Text));

if MemOperator=’^’ then memo1.Text:=floattostr(exp(strtofloat(memo1.Text)*ln(strtofloat(MemAngka))));

MemAngka:=memo1.Text;

MemOperator:=’+';

MemLogic:=’0′;

end;

 

end;

 

procedure TForm1.ButtonMinClick(Sender: TObject);

begin

if (memo1.text<>”) then

if MemLogic=’0′ then MemOperator:=’-‘ else

if (MemOperator=”)  then

begin

MemOperator:=’-‘;

MemLogic:=’0′;

MemAngka:=memo1.Text;

end

else

begin

if MemOperator=’+’ then memo1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(memo1.Text));

if MemOperator=’-‘ then memo1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(memo1.Text));

if MemOperator=’x’ then memo1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(memo1.Text));

if MemOperator=’/’ then memo1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(memo1.Text));

if MemOperator=’mod’ then memo1.Text:=inttostr(strtoint(MemAngka) mod strtoint(memo1.Text));

if MemOperator=’div’ then memo1.Text:=inttostr(strtoint(MemAngka)div strtoint(memo1.Text));

if MemOperator=’^’ then memo1.Text:=floattostr(exp(strtofloat(memo1.Text)*ln(strtofloat(MemAngka))));

MemAngka:=memo1.Text;

MemOperator:=’-‘;

MemLogic:=’0′;

end;

 

end;

 

procedure TForm1.ButtonKaliClick(Sender: TObject);

begin

if (memo1.text<>”) then

if MemLogic=’0′ then MemOperator:=’x’ else

if (MemOperator=”)  then

begin

MemOperator:=’x';

MemLogic:=’0′;

MemAngka:=memo1.Text;

end

else

begin

if MemOperator=’+’ then memo1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(memo1.Text));

if MemOperator=’-‘ then memo1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(memo1.Text));

if MemOperator=’x’ then memo1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(memo1.Text));

if MemOperator=’/’ then memo1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(memo1.Text));

if MemOperator=’mod’ then memo1.Text:=inttostr(strtoint(MemAngka) mod strtoint(memo1.Text));

if MemOperator=’div’ then memo1.Text:=inttostr(strtoint(MemAngka)div strtoint(memo1.Text));

if MemOperator=’^’ then memo1.Text:=floattostr(exp(strtofloat(memo1.Text)*ln(strtofloat(MemAngka))));

MemAngka:=memo1.Text;

MemOperator:=’x';

MemLogic:=’0′;

end;

 

end;

 

procedure TForm1.ButtonBagiClick(Sender: TObject);

begin

if (memo1.text<>”) then

if MemLogic=’0′ then MemOperator:=’/’ else

if (MemOperator=”)  then

begin

MemOperator:=’/';

MemLogic:=’0′;

MemAngka:=memo1.Text;

end

else

begin

if MemOperator=’+’ then memo1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(memo1.Text));

if MemOperator=’-‘ then memo1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(memo1.Text));

if MemOperator=’x’ then memo1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(memo1.Text));

if MemOperator=’/’ then memo1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(memo1.Text));

if MemOperator=’mod’ then memo1.Text:=inttostr(strtoint(MemAngka) mod strtoint(memo1.Text));

if MemOperator=’div’ then memo1.Text:=inttostr(strtoint(MemAngka)div strtoint(memo1.Text));

if MemOperator=’^’ then memo1.Text:=floattostr(exp(strtofloat(memo1.Text)*ln(strtofloat(MemAngka))));

MemAngka:=memo1.Text;

MemOperator:=’/';

MemLogic:=’0′;

end;

 

end;

 

procedure TForm1.ButtonModClick(Sender: TObject);

begin

if (memo1.text<>”) then

if MemLogic=’0′ then MemOperator:=’mod’ else

if (MemOperator=”)  then

begin

MemOperator:=’mod';

MemLogic:=’0′;

MemAngka:=memo1.Text;

end

else

begin

if MemOperator=’+’ then memo1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(memo1.Text));

if MemOperator=’-‘ then memo1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(memo1.Text));

if MemOperator=’x’ then memo1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(memo1.Text));

if MemOperator=’/’ then memo1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(memo1.Text));

if MemOperator=’mod’ then memo1.Text:=inttostr(strtoint(MemAngka) mod strtoint(memo1.Text));

if MemOperator=’div’ then memo1.Text:=inttostr(strtoint(MemAngka)div strtoint(memo1.Text));

if MemOperator=’^’ then memo1.Text:=floattostr(exp(strtofloat(memo1.Text)*ln(strtofloat(MemAngka))));

MemAngka:=memo1.Text;

MemOperator:=’mod';

MemLogic:=’0′;

end;

 

end;

 

procedure TForm1.ButtonDivClick(Sender: TObject);

begin

if (memo1.text<>”) then

if MemLogic=’0′ then MemOperator:=’div’ else

if (MemOperator=”) then

begin

MemOperator:=’div';

MemLogic:=’0′;

MemAngka:=memo1.Text;

end

else

begin

if MemOperator=’+’ then memo1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(memo1.Text));

if MemOperator=’-‘ then memo1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(memo1.Text));

if MemOperator=’x’ then memo1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(memo1.Text));

if MemOperator=’/’ then memo1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(memo1.Text));

if MemOperator=’mod’ then memo1.Text:=inttostr(strtoint(MemAngka) mod strtoint(memo1.Text));

if MemOperator=’div’ then memo1.Text:=inttostr(strtoint(MemAngka)div strtoint(memo1.Text));

if MemOperator=’^’ then memo1.Text:=floattostr(exp(strtofloat(memo1.Text)*ln(strtofloat(MemAngka))));

MemAngka:=memo1.Text;

MemOperator:=’div';

MemLogic:=’0′;

end;

 

end;

 

procedure TForm1.ButtonResultClick(Sender: TObject);

begin

if MemOperator=’+’ then memo1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(memo1.Text));

if MemOperator=’-‘ then memo1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(memo1.Text));

if MemOperator=’x’ then memo1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(memo1.Text));

if MemOperator=’/’ then memo1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(memo1.Text));

if MemOperator=’mod’ then memo1.Text:=inttostr(strtoint(MemAngka) mod strtoint(memo1.Text));

if MemOperator=’div’ then memo1.Text:=inttostr(strtoint(MemAngka)div strtoint(memo1.Text));

if MemOperator=’^’ then memo1.Text:=floattostr(exp(strtofloat(memo1.Text)*ln(strtofloat(MemAngka))));

MemAngka:=memo1.Text;

MemLogic:=’0′;

 

end;

 

procedure TForm1.ButtonKuadratClick(Sender: TObject);

begin

if memo1.text<>” then

memo1.Text:=floattostr(sqr(strtofloat(memo1.Text)));

 

end;

 

procedure TForm1.ButtonPointClick(Sender: TObject);

begin

if memo1.text<>” then

memo1.Text:=memo1.Text + ‘.';

 

end;

 

procedure TForm1.ButtonNotClick(Sender: TObject);

begin

if memo1.text<>” then

memo1.Text:=floattostr(strtofloat(memo1.Text)*(-1));

 

end;

 

procedure TForm1.ButtonAkarClick(Sender: TObject);

begin

if memo1.text<>” then

memo1.Text:=floattostr(sqrt(strtofloat(memo1.Text)));

 

end;

 

procedure TForm1.ButtonPangkatClick(Sender: TObject);

begin

if (memo1.text<>”) then

if MemLogic=’0′ then MemOperator:=’^’ else

if (MemOperator=”) then

begin

MemOperator:=’^';

MemLogic:=’0′;

MemAngka:=memo1.Text;

end

else

begin

if MemOperator=’+’ then memo1.Text:=floattostr(strtofloat(MemAngka)+strtofloat(memo1.Text));

if MemOperator=’-‘ then memo1.Text:=floattostr(strtofloat(MemAngka)-strtofloat(memo1.Text));

if MemOperator=’x’ then memo1.Text:=floattostr(strtofloat(MemAngka)*strtofloat(memo1.Text));

if MemOperator=’/’ then memo1.Text:=floattostr(strtofloat(MemAngka)/strtofloat(memo1.Text));

if MemOperator=’mod’ then memo1.Text:=inttostr(strtoint(MemAngka) mod strtoint(memo1.Text));

if MemOperator=’div’ then memo1.Text:=inttostr(strtoint(MemAngka)div strtoint(memo1.Text));

if MemOperator=’^’ then memo1.Text:=floattostr(exp(strtofloat(memo1.Text)*ln(strtofloat(MemAngka))));

MemAngka:=memo1.Text;

MemOperator:=’^';

MemLogic:=’0′;

end;

 

end;

 

procedure TForm1.ButtonLnClick(Sender: TObject);

begin

if (memo1.text<>”) then

memo1.Text := floattostr(ln(strtofloat(memo1.Text)));

 

end;

 

procedure TForm1.ButtonLogClick(Sender: TObject);

begin

if memo1.Text<=inttostr(0) then memo1.Text :=’Error’

else

if (memo1.text<>”) then

memo1.Text := floattostr(log10(strtofloat(memo1.Text)));

 

end;

 

procedure TForm1.ButtonPerClick(Sender: TObject);

begin

if memo1.Text = ‘0’ then memo1.Text:=’Error divide zero’ else

if memo1.Text<>” then memo1.Text :=floattostr(1/strtofloat(memo1.Text));

MemLogic :=’0′;

 

end;

 

procedure TForm1.ButtonFakClick(Sender: TObject);

var i,n,fak:integer;

begin

if memo1.Text<>” then

begin

n  :=strtoint(memo1.Text);

fak:=1;

for i:=1 to n-1 do

fak:=fak*n;

 

memo1.Text:=inttostr(fak);

MemLogic :=’0′;

end;

 

end;

 

procedure TForm1.ButtonPhiClick(Sender: TObject);

begin

if memo1.Text<>” then memo1.Text := floattostr(pi);

end;

 

procedure TForm1.ButtonSinClick(Sender: TObject);

var sudut:real;

begin

if memo1.Text<>” then

begin

sudut:=strtofloat(memo1.Text);

if RbDeg.Checked = true then  sudut:=sudut*pi/180 else

if RbRad.Checked = true then  sudut:=sudut else

if RbGrads.Checked = true then  sudut:=sudut*pi/200;

memo1.Text := floattostr(sin(sudut));

MemLogic :=’0′;

end;

 

end;

 

procedure TForm1.ButtonCosClick(Sender: TObject);

var sudut:real;

begin

if memo1.Text<>” then

begin

sudut:=strtofloat(memo1.Text);

if RbDeg.Checked = true then  sudut:=sudut*pi/180 else

if RbRad.Checked = true then  sudut:=sudut else

if RbGrads.Checked = true then  sudut:=sudut*pi/200;

memo1.Text := floattostr(cos(sudut));

MemLogic :=’0′;

end;

 

end;

 

procedure TForm1.ButtonTanClick(Sender: TObject);

var sudut:real;

begin

if memo1.Text<>” then

begin

sudut:=strtofloat(memo1.Text);

if RbDeg.Checked = true then  sudut:=sudut*pi/180 else

if RbRad.Checked = true then  sudut:=sudut else

if RbGrads.Checked = true then  sudut:=sudut*pi/200;

memo1.Text := floattostr(tan(sudut));

MemLogic :=’0′;

end;

 

end;

 

procedure TForm1.ButtonMClick(Sender: TObject);

begin

MemSimpan := memo1.Text ;

MemLogic := ‘0’;

MemOperator :=”;

MemAngka := ‘0’;

 

end;

 

procedure TForm1.ButtonMrClick(Sender: TObject);

begin

memo1.Text := MemSimpan ;

end;

 

end.

 

TAMPILAN PROGRAM SELURUHNYA

GB.2 A.Z.I.Z.

T.E.K.N.I.K.I.N.F.O.R.M.T.I.K.A.

APABILA Tombol tidak bias di eksekusi tekan tombol On

Selamat mencoba

 

 

About these ads

21 thoughts on “CARA MEMBUAT APLIKASI KALKULATOR DENGAND DELPHI 7

  1. boz mau tanya donk,
    program delphi ane udh dbikin setupnya pke inno setup,
    trus ane instal hsl setupnya dkomp yg g ad delphiNy,
    ko g bisa dRUN yya,
    tolong pencerahan donk

  2. salam kenal,….saya pemula Delhpi 7.0,…

    saya mau mth,…tip dan trik belajar delphi 7,……

    dan contoh2, program dari Delphi7,….Thx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s