Contoh Pemrograman Timer Delphi

|| || || Leave a komentar
Bagi Info Kita | Pada kesempatan posting kali ini saya ingin berbagi cara bagaimana membuat program agar selayaknya lampu merah dapat berganti pada setiap detiknya. Langsung saja kita praktekkan, sebelumnya kita siapkan terlebih dahulu beberapa komponennya terlebih dahulu yaitu:
Form: Form1
Name : Form1
Caption : Latihan
Selanjutnya
Timer1: Timer1
Shape1: Shpred 
Shape2: Shpblue 
Shape3: Shpgreen 
Shape4: Shpyellow 
untuk listing programnya seperti dibawah ini:


procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if ShpRed.Brush.Color=clRed then
  begin
     Timer1.Interval:=1000;
     ShpRed.Brush.Color:=clwhite;
     ShpGreen.Brush.Color:=clGreen;
     ShpYellow.Brush.Color:=clwhite;
     Shpblue.Brush.Color:=clwhite;
  end
  else if ShpGreen.Brush.Color=clGreen then
  begin
     Timer1.Interval:=1000;
     ShpRed.Brush.Color:=clwhite;
     ShpGreen.Brush.Color:=clwhite;
     ShpYellow.Brush.Color:=clYellow;
     Shpblue.Brush.Color:=clwhite;
  end
  else if Shpyellow.Brush.Color=clyellow then
  begin
     Timer1.Interval:=1000;
     ShpRed.Brush.Color:=clwhite;
     ShpGreen.Brush.Color:=clwhite;
     ShpYellow.Brush.Color:=clwhite;
     Shpblue.Brush.Color:=clblue;
  end
  else
  begin
     Timer1.Interval:=1000;
     ShpRed.Brush.Color:=clRed;
     ShpGreen.Brush.Color:=clwhite;
     ShpYellow.Brush.Color:=clwhite;
     Shpblue.Brush.Color:=clwhite;
  end;
end;


Sekali lagi saya sarankan agar memahami terlebih dahulu jika anda ingin copy/paste listing ini. Semua ilmu akan lebih melekat lama dengan usaha keras dalam memperolehnya. 


/[ 0 komentar Untuk Artikel Contoh Pemrograman Timer Delphi]\

Posting Komentar