Kamis, 05 April 2012


Coding LA Delphi

Menu










unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2, Unit4, Unit3, Unit5;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
form1.Hide;
form2.show;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
form1.Hide;
form4.show;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
form1.Hide;
form3.show;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
form1.Hide;
form5.show;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
close;
end;

end.

Biodata


















unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
form2.Hide;
form1.show;

end;

procedure TForm2.Button2Click(Sender: TObject);
begin
close;

end;

end.

Luas Lingkaran



















unit Unit3;

interface

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

type
  TForm3 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    edit1: TEdit;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);

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

var
  Form3: TForm3;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
begin
form3.Hide;
form1.show;

end;

procedure TForm3.Button2Click(Sender: TObject);
begin
close;

end;

procedure TForm3.Button3Click(Sender: TObject);
var
phi , r, l :real;
begin
r :=strtoint(edit1.text);
phi := 3.14;
l:= phi*r*r;
label4.caption := 'Luas Lingkarannya Adalah' + floattostr(l);
end;
end.

Kondisi


















unit Unit4;

interface

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

type
  TForm4 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form4: TForm4;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm4.Button1Click(Sender: TObject);
var
a : integer;
begin
a:=strtoint(Edit1.Text);
edit2.Text :='';
edit3.Text :='';
if A<50 then
begin
edit2.Text :='Gagal';
edit3.Text :='E';
end
else if A<65 then
begin
edit2.Text :='Lulus';
edit3.Text :='D';
end
else if A<75 then
begin
edit2.Text :='Lulus';
edit3.Text :='C';
end
else if A<85 then
begin
edit2.Text :='Lulus';
edit3.Text :='B';
end
else if A<=100 then
begin
edit2.Text :='Lulus';
edit3.Text :='A';
end
else
begin
edit2.Text :='Salah Input';
edit3.Text :='Ulangi Lagi';

end;
end;
procedure TForm4.Button2Click(Sender: TObject);
begin
Edit1.Text :='';
Edit2.Text :='';
Edit3.Text :='';
end;

procedure TForm4.Button3Click(Sender: TObject);
begin
close;
end;

procedure TForm4.Button4Click(Sender: TObject);
begin
form4.Hide;
form1.show;
end;

end.

Perulangan

















unit Unit5;

interface

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

type
  TForm5 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form5: TForm5;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm5.Button1Click(Sender: TObject);
var
E, F : Integer;
begin
memo1.clear;
E:= StrToInt (edit1.Text);
F:=1;
while F <> StrToInt(edit2.Text) do
begin
memo1.Lines.Add('Perulangan ke-'+IntToStr(F)+' = '+IntToStr(E));
E:= E+1;
F:= F+1;
end;
end;
procedure TForm5.Button2Click(Sender: TObject);
var
E, F : Integer;
begin
memo1.clear;
E:= StrToInt (edit1.Text);
F:=1;
repeat
memo1.Lines.Add('Perulangan ke-'+IntToStr(F)+' = '+IntToStr(E));
F:= F+1;
E:= E+1;
until F = StrToInt(edit2.Text)
end;

procedure TForm5.Button3Click(Sender: TObject);
var
E, F : Integer;
begin
memo1.clear;
E:= StrToInt (edit1.Text);
for F := 1 to StrToInt(edit2.Text) do
begin
memo1.Lines.Add('Perulangan ke-'+IntToStr(F)+' = '+IntToStr(E));
E:= E+1;
end;
end;

procedure TForm5.Button4Click(Sender: TObject);
var
E,F: Integer;
begin
memo1.clear;
E:= StrToInt (edit1.Text);
F:= 1;
for E:= E downto (StrToInt (edit1. Text) - StrToInt (edit2.Text) +1) do
begin
memo1.Lines.Add('Perulangan ke-'+IntToStr(F)+' = '+IntToStr(E));
F:=F+1;
end;
end;

procedure TForm5.Button5Click(Sender: TObject);
begin
close;
end;

procedure TForm5.Button6Click(Sender: TObject);
begin
form5.Hide;
form1.show;

end;

end.

Semoga Berguna ^.^






Tidak ada komentar:

Posting Komentar