RSS

VISUAL BASIC – LATIHAN SOAL (APLIKASI PROGRAM HOTEL)

09 Feb

  • Buat Database dengan nama:penginapan
  • Save di Folder Nim Masing-Masing
  • Buat Tabel Baru :

Kamar

NAME TYPE SIZE Ket
kode_kamar Text 5 Primary Key
jenis_kamar Text 10  
harga Currency 8  

Untuk kamar Isi data Sebanyak 3 Record:

Transaksi

NAME TYPE SIZE Ket
no_trans Text 5 Primary Key
Nama Text 20  
Jenis Text 15  
kode_kamar Text 5  
harga Currency 8  
lama integer 2  
total Currency 8  
ubay Currency 8  
ukem Currency 8  

Buat Desain Form

 

Save di Folder Nim Masing-Masing

Nama Project Penginapan dan Form Hotel

 

Sub aktif()

Txtno.Enabled = True

txtnama.Enabled = True

CboKode.Enabled = True

TxtJenis.Enabled = True

TxtHarga.Enabled = True

TxtLama.Enabled = True

txttobay.Enabled = True

txtubay.Enabled = True

txtukem.Enabled = True

End Sub

Sub nonaktif()

Txtno.Enabled = False

txtnama.Enabled = False

CboKode.Enabled = False

TxtJenis.Enabled = False

TxtHarga.Enabled = False

TxtLama.Enabled = False

txttobay.Enabled = False

txtubay.Enabled = False

txtukem.Enabled = False

End Sub

Sub bersih()

Txtno.Text = “”

txtnama.Text = “”

CboKode.Text = “”

TxtJenis.Text = “”

TxtHarga.Text = “”

TxtLama.Text = “”

txttobay.Text = “”

txtubay.Text = “”

txtukem.Text = “”

End Sub

Sub nomor()

If Trans.Recordset.RecordCount <= 0 Then

no = “T0001”

Else

Trans.Recordset.MoveLast

no = “T” & Right(10001 + Right(Trans.Recordset!no_trans, 4), 4)

End If

Txtno.Text = no

End Sub

Private Sub CboKode_Click(Area As Integer)

Dim a As Byte

a = Len(CboKode.Text)

If a < 5 Then

Exit Sub

End If

With Kamar.Recordset

.Index = “kode_kamar”

.Seek “=”, CboKode.Text

If .NoMatch Then

CboKode.Text = “”

CboKode.SetFocus

Else

Kamar.Refresh

TxtJenis.Text = !jenis_kamar

TxtHarga.Text = !harga

End If

End With

 

End Sub

Private Sub CmdBatal_Click()

Form_Load

End Sub

Private Sub CmdCari_Click()

With Trans.Recordset

.Index = “no_trans”

.Seek “=”, TxtCari.Text

If .NoMatch Then

MsgBox “Data Tidak Ditemukan”, vbInformation, “Pencarian”

TxtCari.SetFocus

Else

Txtno.Text = !no_trans

txtnama.Text = !nama

CboKode.Text = !kode_kamar

TxtJenis.Text = !jenis

TxtHarga.Text = !harga

txttobay.Text = !total

txtubay.Text = !ubay

txtukem.Text = !ukem

TxtLama.Text = !lama

CmdNew.Enabled = False

CmdEdit.Enabled = True

CmdBatal.Enabled = True

End If

End With

End Sub

Private Sub CmdDel_Click()

If Trans.Recordset.RecordCount > 0 Then

a = MsgBox(“Yakin Ingin Menghapus ?”, vbYesNo + vbQuestion, “Hapus ?”)

If a = 6 Then

Trans.Recordset.Delete

End If

End If

End Sub

Private Sub CmdEdit_Click()

aktif

Txtno.Enabled = False

txtnama.SetFocus

CmdEdit.Enabled = False

CmdUpdate.Enabled = True

CmdDel.Enabled = True

End Sub

Private Sub CmdExit_Click()

End

End Sub

Private Sub CmdFirst_Click()

Trans.Recordset.MoveFirst

End Sub

Private Sub CmdLast_Click()

Trans.Recordset.MoveLast

End Sub

Private Sub CmdNew_Click()

bersih

aktif

CmdNew.Enabled = False

nomor

CmdSave.Enabled = True

CmdBatal.Enabled = True

txtnama.SetFocus

End Sub

Private Sub CmdNext_Click()

Trans.Recordset.MoveNext

If Trans.Recordset.EOF Then

MsgBox “Akhir Record”

Trans.Recordset.MoveLast

End If

End Sub

Private Sub CmdPrev_Click()

Trans.Recordset.MovePrevious

If Trans.Recordset.BOF Then

MsgBox “Awal Record”

Trans.Recordset.MoveFirst

End If

End Sub

Private Sub CmdSave_Click()

With Trans.Recordset

.AddNew

!no_trans = Txtno.Text

!nama = txtnama.Text

!jenis = TxtJenis.Text

!kode_kamar = CboKode.Text

!harga = TxtHarga.Text

!total = txttobay.Text

!ubay = txtubay.Text

!ukem = txtukem.Text

!lama = TxtLama.Text

.Update

MsgBox “Data berhasil Disimpan”, vbInformation, “Simpan”

Form_Load

End With

End Sub

Private Sub CmdUpdate_Click()

With Trans.Recordset

.Edit

!no_trans = Txtno.Text

!nama = txtnama.Text

!jenis = TxtJenis.Text

!kode_kamar = CboKode.Text

!harga = TxtHarga.Text

!total = txttobay.Text

!ubay = txtubay.Text

!ukem = txtukem.Text

!lama = TxtLama.Text

.Update

MsgBox “Data berhasil Diupdate”, vbInformation, “Update”

Form_Load

End With

End Sub

Private Sub Form_Load()

bersih

nonaktif

CmdNew.Enabled = True

CmdSave.Enabled = False

CmdEdit.Enabled = False

CmdUpdate.Enabled = False

CmdDel.Enabled = False

CmdBatal.Enabled = False

Trans.Refresh

Txtjml.Text = Trans.Recordset.RecordCount

End Sub

Private Sub TxtLama_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txttobay.Text = Val(TxtHarga.Text) * Val(TxtLama.Text)

txtubay.SetFocus

End If

End Sub

Private Sub txtnama_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

CboKode.SetFocus

End If

End Sub

Private Sub txtubay_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txtukem.Text = Val(txtubay.Text) – Val(txttobay.Text)

CmdSave.SetFocus

End If

End Sub

 

 
2 Komentar

Ditulis oleh pada Februari 9, 2011 in Yuli Bicara Tentang Teknologi

 

2 responses to “VISUAL BASIC – LATIHAN SOAL (APLIKASI PROGRAM HOTEL)

  1. amon

    Februari 9, 2013 at 5:30 am

    maaf saya kesulitan pada saat merancang desain formnya, boleh minta desain formnya?
    ๐Ÿ™‚

     
  2. anggie

    Mei 12, 2013 at 5:11 pm

    mba’ saya mau tanya, waktu mau buat database pd TYPE yg “currency” itu da nama lain gak ya? soalnya saya cari ga ketemu type nya, atau memang saya yg salah? ๐Ÿ˜€ trim’s

     

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

 
%d blogger menyukai ini: