Pada sesi Delphi ini kita akan berlatih menggunakan control Combobos.
Buatlah program menghitung Tarif menginap dihotel dengan ketentuan sebagai berikut:
Input:
- Kelas
- Lama Inap
Biaya Ina Per hari bergantung Kelas
- President Suite, Rp. 600000,-
- Double Bed, Rp. 300000,-
- Single Bed, Rp. 150000
Desain Form
Pengaturan Properti
Penkodean
procedure TfrmTarifHotel.btnOKClick(Sender: TObject); var Kelas, LamaInap: integer; BiayaInap, TotalBayar: real; begin Kelas := cmbKelas.ItemIndex; LamaInap := strtoint(edtLamaInap.Text); if Kelas=0 then BiayaInap := 600000 else if Kelas=1 then BiayaInap := 300000 else BiayaInap := 150000; TotalBayar:=LamaInap*Biayainap; edtBiayaInap.Text:= floattostr(BiayaInap); edtTotalBayar.Text:= floattostr(TotalBayar); end; procedure TfrmTarifHotel.btnResetClick(Sender: TObject); begin cmbKelas.ItemIndex:=0; edtLamaInap.text:=''; edtBiayaInap.Text:= ''; edtTotalBayar.Text:= ''; cmbKelas.setfocus; end; procedure TfrmTarifHotel.Button3Click(Sender: TObject); begin Close end;
Hasil Eksekusi
Iklan
kyaa,,jd inget wktu ngoding vb dlu 😀
mirip..emang VB VS. Delphi…aku lebih suka VB sebenarnya
Kalau menampilkan fiel dari dtbase
Ke kombobox trus saat combobox di pilih
Muncul fiel berikutnya di text bok gimana gan…
Saya punya tabel dengan nama harga
Field nya 1 barang 2 harga_barang
1 combobox dan 1 editbox
Jika combobok dipilih maka otomatis harga tampil di textbox kodingnya gimana ya gan
Mohon penceeahannya
Haloo pak Fairuz….. Materi delphinya belum ada yg terbaru….