Berikut ini akan saya bagikan source code untuk membuat program Kalkulator Sederhana pada Delphi.
Source Codenya :
unit KalkulatorBiasa;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
procedure Button4Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button4Click(Sender: TObject);
var nilai:integer;
begin
nilai:=strtoint(edit1.text)+strtoint(edit2.Text);
edit3.text:=inttostr(nilai);
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
edit1.Text:=' ';
edit2.text:=' ';
edit3.text:=' ';
end;
procedure TForm1.Button3Click(Sender: TObject);
var nilai:integer;
begin
nilai:=strtoint(edit1.text)-strtoint(edit2.Text);
edit3.text:=inttostr(nilai);
end;
procedure TForm1.Button2Click(Sender: TObject);
var nilai:integer;
begin
nilai:=strtoint(edit1.text)*strtoint(edit2.Text);
edit3.text:=inttostr(nilai);
end;
procedure TForm1.Button1Click(Sender: TObject);
var nilai:real;
begin
nilai:=strtofloat(edit1.text)/strtofloat(edit2.Text);
edit3.text:=floattostr(nilai);
end;
procedure TForm1.Button5Click(Sender: TObject);
var nilai:integer;
begin
nilai:=strtoint(edit1.text) div strtoint(edit2.Text);
edit3.text:=inttostr(nilai);
end;
procedure TForm1.Button6Click(Sender: TObject);
var nilai:integer;
begin
nilai:=strtoint(edit1.text) mod strtoint(edit2.Text);
edit3.text:=inttostr(nilai);
end;
end.
Jika sudah dimasukkan source code seperti di atas maka ketika program dijalankan akan tampil seperti ini :
Sekian dari saya, semoga bermanfaat. Terima Kasih...
Untuk download programnya, silahkan download (DISINI)
Selasa, 28 Oktober 2014
Contoh Program Kalkulator Sederhana pada Delphi
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar