Contoh Penggunaan Case Of Pada Delphi

procedure TForm1.Button1Click(Sender: TObject);
var nilai : integer;
begin
nilai:=StrToInt(edit1.Text);
case nilai of
0..15:label3.Caption:='NILAI ANDA = E';
16..40:label3.Caption:='NILAI ANDA = D';
41..60:label3.Caption:='NILAI ANDA = C';
61..80:label3.Caption:='NILAI ANDA = B';
81..100:label3.Caption:='NILAI ANDA = A'
else
label3.Caption:='Waduh…. Sekolah Aja lu';
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if Application.MessageBox('Yakin Mu Keluar??','Konfirmasi',MB_OKCANCEL)=mrok then
close;
end;


0 komentar: