Kali ini saya akan posting syntax dalam pembuatan program daftar belanja sederhana, untuk itu mari simak dengan baik :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
GroupBox2: TGroupBox;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
GroupBox3: TGroupBox;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Edit9: TEdit;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
GroupBox4: TGroupBox;
Edit13: TEdit;
Edit14: TEdit;
Edit15: TEdit;
Edit16: TEdit;
GroupBox5: TGroupBox;
Edit17: TEdit;
Edit18: TEdit;
Edit19: TEdit;
Edit20: TEdit;
Button1: TButton;
Button2: TButton;
Edit21: TEdit;
Label14: TLabel;
Edit22: TEdit;
Label15: TLabel;
Button3: TButton;
Edit23: TEdit;
Label16: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var hrgDasMb, hrgDasPros, HrgDasHd, hrgaDasRam:Currency;
jmlMb, jmlPros, jmlHd, jmlRam:Integer;
TotMb, TotPros, TotHd, TotRam,a,b:Currency;
begin
//MENDEKLARASIKAN HARGA SATUAN
hrgDasMb:=StrToCurr(Edit9.Text);
hrgDasPros:=StrToCurr(Edit10.Text);
HrgDasHd:=StrToCurr(Edit11.Text);
hrgaDasRAM:=StrToCurr(Edit12.Text);
a:=StrToCurr(Edit23.Text);
//MENDEKLARASIKAN UMLAH PEMBELIAN
jmlMb:=StrToInt(Edit13.Text);
jmlPros:=StrToInt(Edit14.Text);
jmlHD:=StrToInt(Edit15.Text) ;
jmlRam:=StrToInt(Edit16.Text);
//a:=StrToInt(Edit23.Text);
//MENGHITUNG HARGA DASAR X BELI
TotMb:=hrgDasMB*jmlMb;
TotPros:=hrgDasPROS*jmlPros;
TotHD:=HrgDasHd*jmlHD;
TotRam:=hrgaDasRam*jmlRam;
//Menulis Hasil ke lompatan Total
Edit17.Text:=CurrToStr(TotMb);
Edit18.Text:=CurrToStr(TotPros);
Edit19.Text:=CurrToStr(TotHd);
Edit20.Text:=CurrToStr(TotRam);
Edit21.Text:=CurrToStr(TotMb+TotPros+TotHd+TotRam);
b:=a /100;
//diskon
Edit22.Text:=CurrToStr((TotMb+TotPros+TotHd+TotRam)*b);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Edit13.Clear;Edit14.Clear;Edit15.Clear;Edit16.Clear;Edit17.Clear;Edit18.Clear;Edit19.Clear;
Edit20.Clear;
Edit13.SetFocus
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit17.Text:=CurrToStr(StrToCurr(Edit9.Text) *StrToInt(Edit13.Text));
Edit18.Text:=CurrToStr(StrToCurr(Edit10.Text)*StrToInt(Edit14.Text));
Edit19.Text:=CurrToStr(StrToCurr(Edit11.Text) * StrToInt(Edit15.Text));
Edit20.Text:=CurrToStr(StrToCurr(Edit12.Text)* StrToInt(Edit16.Text));
Edit21.Text:=CurrToStr(StrToCurr(Edit13.Text)* StrToInt(Edit17.Text) +
StrToCurr(Edit19.Text)+ StrToCurr(Edit20.Text));
end;
end.
0 komentar
Posting Komentar