file · web viewmessagedlg('angka yang anda masukkan gak temasuk dalam range...

3
Lesson 2 – Kondisi / Percabangan (If … Then .. Else) – http://kubaat.wordpress.com /les-komputer Kondisi / Percabangan (If .. Then .. Else) atau (Case) Aplikasi Nilai Huruf (If ... Then .. Else) procedure TForm1.bKeluarClick(Sender: TObject); var jawab : integer; begin jawab := MessageDlg('Anda Yakin Ingin Keluar.. ?', mtConfirmation, [mbYes, mbNo], 0); if jawab = mrYes then Close; end; procedure TForm1.bProsesClick(Sender: TObject); var nilai : integer; begin nilai := strtoint(txtnilai.Text); if ((nilai <= 100) and (nilai > 80)) then txthuruf.Text := 'A' else if ((nilai <= 80) and (nilai > 70)) then txthuruf.Text := 'B' else if ((nilai <= 70) and (nilai > 60)) then txthuruf.Text := 'C' else if ((nilai <= 60) and (nilai > 45)) then txthuruf.Text := 'D' else if ((nilai <= 45) and (nilai > 0)) then txthuruf.Text := 'E' else begin MessageDlg('Nilai harus antara 0-100 !!!', mtInformation, [mbOK],0 );

Upload: vucong

Post on 06-Feb-2018

219 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: file · Web viewMessageDlg('Angka yang anda masukkan gak temasuk dalam range 1-6', mtInformation, [mbOK], 0);

Lesson 2 – Kondisi / Percabangan (If … Then .. Else) – http://kubaat.wordpress.com /les-komputer

Kondisi / Percabangan (If .. Then .. Else) atau (Case)

Aplikasi Nilai Huruf (If ... Then .. Else)

procedure TForm1.bKeluarClick(Sender: TObject);varjawab : integer;begin jawab := MessageDlg('Anda Yakin Ingin Keluar.. ?', mtConfirmation, [mbYes, mbNo], 0); if jawab = mrYes then Close;end;

procedure TForm1.bProsesClick(Sender: TObject);varnilai : integer;begin nilai := strtoint(txtnilai.Text); if ((nilai <= 100) and (nilai > 80)) then txthuruf.Text := 'A' else if ((nilai <= 80) and (nilai > 70)) then txthuruf.Text := 'B' else if ((nilai <= 70) and (nilai > 60)) then txthuruf.Text := 'C' else if ((nilai <= 60) and (nilai > 45)) then txthuruf.Text := 'D' else if ((nilai <= 45) and (nilai > 0)) then txthuruf.Text := 'E' else begin MessageDlg('Nilai harus antara 0-100 !!!', mtInformation, [mbOK],0 ); txtnilai.Text := ''; txthuruf.Text := ''; txtnilai.SetFocus; endend;

Page 2: file · Web viewMessageDlg('Angka yang anda masukkan gak temasuk dalam range 1-6', mtInformation, [mbOK], 0);

Lesson 2 – Kondisi / Percabangan (If … Then .. Else) – http://kubaat.wordpress.com /les-komputer

Aplikasi Angka Terbilang (Case ... Of)

procedure TForm1.bProsesClick(Sender: TObject);varangka : integer;begin angka := strtoint(txtangka.Text); Case angka of 1 : txtterbilang.Text := 'Satu'; 2 : txtterbilang.Text := 'Dua'; 3 : txtterbilang.Text := 'Tiga'; 4 : txtterbilang.Text := 'Empat'; 5 : txtterbilang.Text := 'Lima'; 6 : txtterbilang.Text := 'Enam'; else MessageDlg('Angka yang anda masukkan gak temasuk dalam range 1-6', mtInformation, [mbOK], 0); end;end;