Minggu, 02 Maret 2008

Percabangan (Latihan 3)

Bentuk Tampilan Hasil :




Listing Program (catatan Edit dalam delphi bertipe data string jadi setiap ingin melakukan perubahan nilai tipe data maka harus dirumah ketipe data yang diinginkan).
procedure TForm2.FormCreate(Sender: TObject);begincombobox1.Items.Add (’ads’);combobox1.Items.Add (’rbk’);combobox1.Items.Add (’spt’);end;
procedure TForm2.ComboBox1Click(Sender: TObject);beginif combobox1.Text=’ads’ then begin enama.Text :=’Adidas’; eharga.Text:=’250000′; endelseif combobox1.Text=’rbk’ then begin enama.Text :=’Reebok’; eharga.Text:=’200000′; endelse begin enama.Text :=’Spotec’; eharga.Text:=’150000′; end;end;
procedure TForm2.rb1Click(Sender: TObject);var c,a,d:real;beginif rb1.Checked =true then c:=strtofloat(eharga.Text);——->Tipe data String dirubah menjadi tipe data real/float a:=c*5/100; d:=a+c; etotbay.Text:=floattostr(d); ebayar.SetFocusend;
procedure TForm2.rb2Click(Sender: TObject);var c,a,d:real;beginif rb2.Checked =true then c:=strtofloat(eharga.Text); a:=c*10/100; d:=a+c; etotbay.Text:=floattostr(d); ebayar.SetFocusend;
procedure TForm2.ebayarChange(Sender: TObject);var a:real;begina:=strtofloat(ebayar.Text)- strtofloat(etotbay.Text);ekembali.Text:=floattostr(a);end;
procedure TForm2.bbersihClick(Sender: TObject);begincombobox1.Text:=’Pilih Kode’;enama.Text:=”;eharga.Text:=’0′;etotbay.Text:=’0′;ebayar.Text:=’0′;ekembali.Text :=’0′;end;


Untuk Pesan Kita bisa buat tampilan seperti ini :




procedure TForm2.bkeluarClick(Sender: TObject);
begin
if messagedlg(’Anda ingin keluar ?’,mtconfirmation,[mbyes,mbno],0)=mryes then
close;
end;

Selamat Mencoba….

0 komentar: