Friday, March 30, 2012

cara membuat menu, perulangan dan timer pada delphi

Buatlah Logika masing-masing :) 

buat lah 3 form terlebih dahulu. File --> New --> Form.
Form 1 : Main Menu
Form 2 : - GroupBox
              - Label
              - Edit
              - Memo
              - Button
Form 3: - Timer
             - Button
             - Label



Pada Form 1 : 

listing pada Perulangan :
*tampilin form 2* 

Code Pada timer :
*tampilin form 3*
Exit :
Application.Terminate ;
Pada Form 2:
name ga usah diganti nanti ribet, tapi serah sik
- Group Box : Caption : perulangan 
- Label 1 :  Caption : Angka Awal
- label 2 : Caption :Angka Akhir
- Edit 1 : Text : (kosongkan) 
- Edit 2 : Text : (kosongkan)
- Button1: Caption : For_do
- Button2: Caption : for_downto
- Button3: Caption : Back 
Code/Script : 
- Button for_do :
procedure TForm2.Button1Click(Sender: TObject);
var a,b,c,d:Integer;
begin
memo1.Clear;
a:=StrToInt(Edit1.text);
b:=StrToInt(Edit2.Text);
for c:= a to b do
  begin
  d :=Sqr(c);
  memo1.Lines.add(IntToStr(c) + ' Kuadrat = ' + IntToStr(d));
end;
end;
- Button for_downto do :

procedure TForm2.Button2Click(Sender: TObject);
var a,b,c,d:Integer;
begin
memo1.clear;
a:=StrToInt(Edit1.text);
b:=StrToInt(Edit2.Text);
for c:= b downto a do
   begin
   d:=Sqr(c);
   memo1.Lines.add(IntToStr(c) + ' Kuadrat = ' + IntToStr(d));
end;
end;
- Button Back :
procedure TForm2.Button3Click(Sender: TObject);
begin
form1.show;
form2.hide ;
form3.hide;
end;
end.

Form 3:

- Klik 2x pada Timer :
procedure TForm3.Timer1Timer(Sender: TObject);
begin
label1.Caption:=ini cari sendiri *jangan pake DateToStr yaa* :p
label2.caption:=sama kaya ^^
end;
end.
- Klik 2x pada Button : 
procedure TForm3.Button1Click(Sender: TObject);
begin
form1.show;
form2.hide;
form3.Hide;
end;

soal LP
1. apa yang kalian ketahui tentang database pada delphi
2. jelaskan langkah-langkah membuat database pada delphi

muahaha maaf yaa soal LP nya telat bgt, lupa ehehehe maaf nya *o~/ *sungkem satu-satu*

sb: http://toerzun.blogspot.com/2012/03/program-menu-submenu-perulangan-dan.html

9 comments: