Sabtu, 05 Mei 2012
Tugas 4
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ForToDo: TButton;
ForDowntoDo: TButton;
WhileDo: TButton;
RepeatUntil: TButton;
bt_pangkat: TButton;
btKeluar: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
bil: TLabel;
Pangkat: TLabel;
hasil: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Binput: TButton;
Label5: TLabel;
Label6: TLabel;
lnama: TLabel;
lnim: TLabel;
procedure btKeluarClick(Sender: TObject);
procedure ForToDoClick(Sender: TObject);
procedure ForDowntoDoClick(Sender: TObject);
procedure WhileDoClick(Sender: TObject);
procedure RepeatUntilClick(Sender: TObject);
procedure bt_pangkatClick(Sender: TObject);
procedure BinputClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btKeluarClick(Sender: TObject);
begin
if(application.MessageBox('Keluar Aplikasi ?','konfirmasi',mb_yesno)=idyes)then
close;
end;
procedure TForm1.ForToDoClick(Sender: TObject);
var
i,j:integer;b:string;
begin
b:='';j:=2;
for i:=1 to 10 do
begin
b:=b+inttostr(i)+'';
j:=j+2;
end;
label1.Caption:=b;
end;
procedure TForm1.ForDowntoDoClick(Sender: TObject);
var
i,j:integer;b:string;
begin
b:='';j:=2;
for i:=10 downto 1 do
begin
b:=b+inttostr(i)+'';
j:=j+2;
end;
label2.caption:=b;
end;
procedure TForm1.WhileDoClick(Sender: TObject);
var
i,j:integer;b:string;
begin
i:=1;
b:='';
while i<=10 do
begin
b:=b+inttostr(i)+'';
i:=i+1;
end;
label3.Caption:=b;
end;
procedure TForm1.RepeatUntilClick(Sender: TObject);
var
i,j:integer;b:string;
begin
i:=1;
b:='';
repeat
b:=b+inttostr(i)+'';
i:=i+1;
until i>10;
label4.caption:=b;
end;
procedure TForm1.bt_pangkatClick(Sender: TObject);
var
bil,hasil,pangkat,a:integer;
begin
bil:=strtoint(edit1.Text);
hasil:=bil;
pangkat:=strtoint(edit2.Text);
if edit2.text='0'then edit3.Text:='1'else
if edit2.text='1'then edit3.Text:=edit1.text else
begin
for a:=2 to pangkat do
hasil:=hasil*bil;
edit3.Text:=inttostr(hasil);
lnama.Caption:='Krisdian Eko Robbyanto';
lnim.Caption:='111221054';
end;
end;
procedure TForm1.BinputClick(Sender: TObject);
begin
edit1.Clear;
edit2.Clear;
edit3.clear;
lnama.caption:='';
lnim.Caption:='';
label1.Caption:='';
label2.Caption:='';
label3.Caption:='';
label4.Caption:='';
end;
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar