Label

Case..Of (1) Delphi (3) ELSE (1) Event (1) form (1) form..to (1) Linux (1) Object (1) Percabangan IF (1) program (2) Repeat..until (1) THEN (1) while..do (1) windows (1)

Jumat, 11 Desember 2009

Contoh Latihan 1

1. Buatlah program seperti berikut :



Komponen/Objek yang digunakan dan pengaturan propertiesnya adalah :



Masukkan perintah-perintah pada kejadian/event disetiap komponen di bawah ini.


Program lengkapnya adalah :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
btJumlah: TButton;
btKurang: TButton;
Label1: TLabel;
Label2: TLabel;
edAng1: TEdit;
edAng2: TEdit;
btBagi: TButton;
btKali: TButton;
Panel1: TPanel;
Label3: TLabel;
edHasil: TEdit;
Panel2: TPanel;
LMerah: TLabel;
LBiru: TLabel;
LHijau: TLabel;
procedure btJumlahClick(Sender: TObject);
procedure btKurangClick(Sender: TObject);
procedure btKaliClick(Sender: TObject);
procedure btBagiClick(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure LMerahMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure LBiruMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure LHijauMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}

procedure TForm1.btJumlahClick(Sender: TObject);
var a,b : integer;
begin
a := StrToInt(edAng1.Text);
b := StrToInt(edAng2.Text);
edHasil.Text := IntToStr(a + b);
end;
procedure TForm1.btKurangClick(Sender: TObject);
var a,b : integer;
begin
a := StrToInt(edAng1.Text);
b := StrToInt(edAng2.Text);
edHasil.Text := IntToStr(a - b);

procedure TForm1.btBagiClick(Sender: TObject);
var a,b : integer;
begin
a := StrToInt(edAng1.Text);
b := StrToInt(edAng2.Text);
edHasil.Text := FloatToStr(a / b);
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Form1.Color := clBtnFace;
end;
procedure TForm1.LMerahMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Form1.Color := clRed;
end;
procedure TForm1.LBiruMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Form1.Color := clBlue;
end;
procedure TForm1.LHijauMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Form1.Color := clGreen;
end;

Tidak ada komentar:

Posting Komentar