Program Sistem Informasi Sewa Kamar Hotel di VB6 Part2

Baru saja kita sudah menjalaskan bagaiamana jalannya program sewa kamar hotel dan bagaimana cara mendesain Formnya yang sudah dijelaskan pada Part1.

Form1 pada Part1


Sekarang kita akan melnjutkan ke Part2 nya yaitu untuk membuta kode programnya.

Berikut adalah Kode Program pada Part1:


KODE PROGRAM


Sub FormatAwal()

Text1.Text = "Nama Lengkap"

Text1.Appearance = 0

Text1.ForeColor = &HC0C0C0

Text1.FontBold = True


Text2.Text = "No.Identitas"

Text2.Appearance = 0

Text2.ForeColor = &HC0C0C0

Text2.FontBold = True


Text3.Text = "Alamat"

Text3.Appearance = 0

Text3.ForeColor = &HC0C0C0

Text3.FontBold = True


Text4.Text = "No.Tlp"

Text4.Appearance = 0

Text4.ForeColor = &HC0C0C0

Text4.FontBold = True


Label4.BackStyle = 0

Label5.BackStyle = 0

Label6.BackStyle = 0

Label7.BackStyle = 0

Label8.BackStyle = 0

Label9.BorderStyle = 1

Label9.Caption = "0"

Label10.BackStyle = 0

Label11.BorderStyle = 1

Label11.Caption = "0"

Label12.BackStyle = 0

Label13.Caption = "0"

Label13.BorderStyle = 1

Label14.BackStyle = 0

Label14.Caption = "Perintah : Isikan identitas tamu"


Option1.BackColor = &H4080&

Option2.BackColor = &H4080&

Option3.BackColor = &H4080&

Option4.BackColor = &H4080&

Option5.BackColor = &H4080&

Option6.BackColor = &H4080&

Option1.ForeColor = vbWhite

Option2.ForeColor = vbWhite

Option3.ForeColor = vbWhite

Option4.ForeColor = vbWhite

Option5.ForeColor = vbWhite

Option6.ForeColor = vbWhite

Option5.Enabled = False

Option6.Enabled = False


Combo1.AddItem "1"

Combo1.AddItem "2"

Combo1.AddItem "3"

List1.AddItem "0"

List1.AddItem "1"

List1.AddItem "2"

List1.AddItem "3"

Combo1.Text = 0

Combo1.FontBold = True


DTPicker1.Format = dtpLongDate

DTPicker2.Format = dtpLongDate

DTPicker1.Value = Now

DTPicker1.Enabled = False

DTPicker2.Value = Now

Command2.Enabled = False

End Sub


Private Sub Command1_Click()

Combo1.Clear

List1.Clear

Call FormatAwal

Option1.Value = False

Option2.Value = False

Option3.Value = False

Option4.Value = False

Option5.Value = False

Option6.Value = False

Command2.Enabled = False

Command1.Caption = "BATAL"

Text1.SetFocus

End Sub


Private Sub Command2_Click()

If Text1 = "Nama Lengkap" Or Text2.Text = "No.Identitas" Or Text3.Text = "Alamat" Or Text4.Text = "No.Tlp" Then

     MsgBox "Lengkapi Data Tamu", vbOKOnly, "Perhatian"

     Text1.SetFocus


Else

   If Label9.Caption = 0 Then

      MsgBox "Tanggal Check-Out belum ditentukan", vbOKOnly, "Perhatian"

   Else


      If Combo1.Text = 0 Then

         MsgBox "Silahkan pilih Jumlah  Kamar", vbOKOnly, "Perhatian"

         Combo1.SetFocus

         Else

             If Option1.Value = False And Option2.Value = False And Option3.Value = False And Option4.Value = False Then

                MsgBox "Silahkan pilih Type Kamar", vbOKOnly, "Perhatian"

                Else


                Dim Masuk, Keluar As String

                Dim Lama As Integer

                Masuk = DTPicker1

                Keluar = DTPicker2

                Lama = DateDiff("d", Masuk, Keluar)

                Label9.Caption = Lama

                bayar = Val(Label9) * Val(Label13) * Combo1

                Label11.Caption = Format(bayar, "Rp ###,##") & ",-"

                Command1.Caption = "Clear"

             End If

         End If

     End If

    Command1.SetFocus

     Label14.Caption = "Perintah : Klik Tombol Clear untuk mengulangi transaksi"

End If

End Sub


Private Sub DTPicker2_Change()

Dim Masuk, Keluar As String

Dim Lama As Integer

Masuk = DTPicker1

Keluar = DTPicker2

Lama = DateDiff("d", Masuk, Keluar)

Label9.Caption = Lama

Label14.Caption = "Perintah : Pilih Type Kamar"

End Sub


Private Sub Form_Load()

Call FormatAwal

End Sub


Private Sub List1_Click()

If Combo1.Text = 0 Or List1.Text = 0 Then

Else

Option5.Enabled = True

Option6.Enabled = True

Label14.Caption = "Perintah : Masukan Jumlah Tamu"

End If

Label14.Caption = "Perintah : Pilih Metode Pembayaran"

End Sub


Private Sub Option1_Click()

Label13.Caption = 150000

Label14.Caption = "Perintah : Pilih Jumlah Kamar"

End Sub


Private Sub Option2_Click()

Label13.Caption = 200000

Label14.Caption = "Perintah : Pilih Jumlah Kamar"

End Sub


Private Sub Option3_Click()

Label13.Caption = 250000

Label14.Caption = "Perintah : Pilih Jumlah Kamar"

End Sub


Private Sub Option4_Click()

Label13.Caption = 300000

Label14.Caption = "Perintah : Pilih Jumlah Kamar"

End Sub


Private Sub Option5_Click()

Command2.Enabled = True

Label14.Caption = "Perintah : Tekan Bayar"

End Sub


Private Sub Option6_Click()

Command2.Enabled = True

End Sub


Private Sub Text1_Click()

If Text1.Text = "Nama Lengkap" Then

Text1.Text = ""

Text1.ForeColor = vbBlack

End If

End Sub


Private Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Text2.SetFocus

Text2.Text = ""

End If


If Text1.Text = "Nama Lengkap" Then

Text1.Text = ""

Text1.ForeColor = vbBlack

End If

End Sub


Private Sub Text1_LostFocus()

If Text1.Text = "" Then

Text1.Text = "Nama Lengkap"

Text1.ForeColor = &HC0C0C0

End If

End Sub


Private Sub Text2_Click()

If Text2.Text = "No.Identitas" Then

Text2.Text = ""

Text2.ForeColor = vbBlack

End If

End Sub


Private Sub Text2_KeyPress(KeyAscii As Integer)

Text2.ForeColor = vbBlack

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete Or KeyAscii = vbKeySpace Or KeyAscii = vbKeyReturn) Then

MsgBox "Maaf Hanya Boleh Diisi Angka Saja", vbInformation + vbOKOnly, "Perhatian"

KeyAscii = 0

End If


If KeyAscii = 13 Then

Text3.SetFocus

Text3.Text = ""

End If


If Text2.Text = "No.Identitas" Then

Text2.Text = ""

Text2.ForeColor = vbBlack

End If

End Sub


Private Sub Text2_LostFocus()

If Text2.Text = "" Then

Text2.Text = "No.Identitas"

Text2.ForeColor = &HC0C0C0

End If

End Sub


Private Sub Text3_Click()

If Text3.Text = "Alamat" Then

Text3.Text = ""

Text3.ForeColor = vbBlack

End If

End Sub


Private Sub Text3_KeyPress(KeyAscii As Integer)

Text3.ForeColor = vbBlack

If KeyAscii = 13 Then

Text4.SetFocus

Text4.Text = ""

End If


If Text3.Text = "Alamat" Then

Text3.Text = ""

Text3.ForeColor = vbBlack

End If

End Sub


Private Sub Text3_LostFocus()

If Text3.Text = "" Then

Text3.Text = "Alamat"

Text3.ForeColor = &HC0C0C0

End If

End Sub


Private Sub Text4_Click()

If Text4.Text = "No.Tlp" Then

Text4.Text = ""

Text4.ForeColor = vbBlack

End If

End Sub


Private Sub Text4_KeyPress(KeyAscii As Integer)

Text4.ForeColor = vbBlack

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack Or KeyAscii = vbKeyDelete Or KeyAscii = vbKeySpace Or KeyAscii = vbKeyReturn) Then

MsgBox "Maaf Hanya Boleh Diisi Angka Saja", vbInformation + vbOKOnly, "Perhatian"

KeyAscii = 0

End If


If Text4.Text = "No.Tlp" Then

Text4.Text = ""

Text4.ForeColor = vbBlack

End If


If KeyAscii = 13 Then

DTPicker2.SetFocus

Label14.Caption = "Perintah : Pilih tanggal Check-Out"

End If

End Sub


Private Sub Text4_LostFocus()

If Text4.Text = "" Then

Text4.Text = "No.Tlp"

Text4.ForeColor = &HC0C0C0

End If

End Sub


Sekarang jalankan program Anda, jika tidak ada erorr hasil programnya akan tampak pada gambar dibawah ini :

Output Program

Perhatian:

  • Kode Program ini sudah di RUN dan berjalan dengan baik tanpa Erorr.
  • Silahkan kembangkan kembali program ini sesuai selera anda kalau bisa gunakan database access

Demikianlah artikel dari saya cara membuat program sistem informasi sewa kamar hotel di vb6, semoga artikel ini bermanfaat buat kit semua.Amin

Selamat mencoa semoga sukses


No comments: