4. Listing Program
Option Strict Off
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim harga, harga_bayar, total_bayar, diskon, korting As Integer
Dim a As Date = DateTimePicker1.Value
Dim b As Date = DateTimePicker2.Value
'karena hari dimana dimulai dan diakhiri transaksi dihitung 1 hari
Dim lama As Int32 = b.DayOfYear - a.DayOfYear + 1
Dim nm_kamar As String
If TextBox1.Text = "" Then
MessageBox.Show("Anda Belum Memasukkan Nama
Pengunjung", "Peringatan", MessageBoxButtons.OK,
MessageBoxIcon.Warning)
TextBox1.Focus()
5. Lanjutan
ElseIf ComboBox1.Text = "" Then
MessageBox.Show("Anda Belum Memilih kamar", "Peringatan",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
ComboBox1.Focus()
ElseIf ComboBox2.Text = "" Then
MessageBox.Show("Anda Belum Memilih No. kamar",
"Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ComboBox1.Text = ""
ComboBox2.Focus()
ElseIf DateTimePicker2.Value <= Now Then
MessageBox.Show("Anda Belum Memasukkan tanggal CekOut",
"Peringatan", MessageBoxButtons.OK, MessageBoxIcon.Warning)
DateTimePicker2.Focus()
End If
If ComboBox1.Text = "Mawar" Then
nm_kamar = "Mawar"
TextBox2.Text = "Rp. 200.000,-"
harga = 200000
ElseIf ComboBox1.Text = "Melati" Then
6. Lanjutan
nm_kamar = "Melati"
TextBox2.Text = "Rp. 150.000,-"
harga = 150000
ElseIf ComboBox1.Text = "Cempaka" Then
nm_kamar = "Cempaka"
TextBox2.Text = "Rp. 100.000,-"
harga = 100000
End If
If (lama >= 10) Then
korting = 75
diskon = harga * (korting / 100)
harga_bayar = lama * harga
total_bayar = ((lama - 1) * harga) + diskon
TextBox5.Text = "75"
ElseIf (lama >= 7) Then
korting = 50
diskon = harga * (korting / 100)
harga_bayar = lama * harga
total_bayar = ((lama - 1) * harga) + diskon
TextBox5.Text = "50"
ElseIf (lama >= 5) Then
korting = 35
7. Lanjutan
diskon = harga * (korting / 100)
harga_bayar = lama * harga
total_bayar = ((lama - 1) * harga) + diskon
TextBox5.Text = "35"
ElseIf (lama >= 3) Then
korting = 20
diskon = harga * (korting / 100)
harga_bayar = lama * harga
total_bayar = ((lama - 1) * harga) + diskon
TextBox5.Text = "20"
Else
diskon = 0
harga_bayar = lama * harga
total_bayar = harga_bayar + diskon
TextBox5.Text = "0"
End If
TextBox4.Text = "Rp. " & harga_bayar
TextBox6.Text = "Rp. " & total_bayar
ListBox1.Items.Add(TextBox1.Text)
ListBox2.Items.Add(DateTimePicker1.Value.Date)
ListBox3.Items.Add(DateTimePicker2.Value.Date)
8. Lanjutan
ListBox4.Items.Add(ComboBox1.Text)
ListBox5.Items.Add(ComboBox2.Text)
ListBox6.Items.Add("Rp. " & total_bayar)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'menyembunyikan salam pembuka
SplashScreen.Hide()
TextBox1.Focus()
TextBox2.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
ListBox1.Enabled = False
ListBox2.Enabled = False
ListBox3.Enabled = False
ListBox4.Enabled = False
ListBox5.Enabled = False
9. Lanjutan
ListBox6.Enabled = False
With ComboBox1
.Items.Add("Mawar")
.Items.Add("Melati")
.Items.Add("Cempaka")
End With
With ComboBox2
.Items.Add("1")
.Items.Add("2")
.Items.Add("3")
.Items.Add("4")
.Items.Add("5")
.Items.Add("6")
.Items.Add("7")
.Items.Add("8")
.Items.Add("9")
.Items.Add("10")
End With
10. Lanjutan
ListBox7.Items.Add("Nama")
ListBox8.Items.Add("Masuk")
ListBox9.Items.Add("Keluar")
ListBox10.Items.Add("Type")
ListBox11.Items.Add("No")
ListBox12.Items.Add("Total Bayar")
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
'keluar
End
'menutup pembuka
SplashScreen.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
AboutBox1.Show()
End Sub
11. Lanjutan
Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Clear.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
DateTimePicker2.Value = Now
ComboBox1.Text = ""
ComboBox2.Text = ""
End Sub
End Class