Sunday, July 31, 2011

Check Nilai 2

unit Unit1;

interface

uses
Windows, SysUtils, Graphics, Forms, StdCtrls, ExtCtrls, Controls, Classes;

type
TForm1 = class(TForm)
// Componnent yg diperlukan----------------------------------------------------->
E1: TEdit;
S1: TShape;
procedure E1Change(Sender: TObject);
private
{ By : Zephio
Check Nilai antara 1..100 }
public
{ http://amateur-guide.blogspot.com }
end;

var
Form1: TForm1;

implementation



{$R *.dfm}

procedure TForm1.E1Change(Sender: TObject);
var
I : Integer;
begin
E1.MaxLength := 3; //Batas Maximal Input adalah 3 Digit / [0..999]
I := StrToInt(E1.Text); //I = Input Nilai
case I of
// Dengan Text
1..20 : Caption := 'E = Sangat Payah'; // Jika Input Antara 1 hingga 20 maka tampilkan Pesan E
21..40 : Caption := 'D = Payah'; // Jika Input Antara 21 hingga 40 maka tampilkan Pesan D
41..60 : Caption := 'C = Lumayan'; // Jika Input Antara 41 hingga 60 maka tampilkan Pesan C
61..80 : Caption := 'B = Bagus'; // Jika Input Antara 61 hingga 80 maka tampilkan Pesan B
81..100 : Caption := 'A = Sempurna'; // Jika Input Antara 81 hingga 100 maka tampilkan Pesan A
0, 101..999 : Caption := '? = Diluar Nilai'; // Jika Input adalah 0 Antara 101 hingga 999 maka Pengecualian
else
Caption := '';
end;
case I of
// Dengan Color
1..20 : S1.Brush.Color := ClRed;
21..40 : S1.Brush.Color := clFuchsia;
41..60 : S1.Brush.Color := ClYellow;
61..80 : S1.Brush.Color := ClBlue;
81..100 : S1.Brush.Color := ClGreen;
0, 101..MaxInt : S1.Brush.Color := ClBlack;
else
S1.Brush.Color := ClWhite;
end;
end;

end.

No comments:

Post a Comment