Selesaikanlah Kasus Berikut :
Public Class Form1
selamat belajar bahasa pemograman dan jangan lupa kunjungi blog pak mesran
Modifikasi program berikut ini http://mesran.blogspot.com/2013/11/pemakaian-if-else-dalam-penyelesaian.html dengan menambahkan komponen LISTVIEW
(http://mesran.net/quiz.html)
Berikut ini adalah jawabannya
buat terlebih dahulu desain formnya
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BuatTabel()
kp.Items.Add("PAB-MED-100")
kp.Items.Add("TOK-BEL-101")
kp.Items.Add("SWA-MED-102")
kp.Items.Add("SAL-BEL-103")
kp.Items.Add("GRO-DEL-104")
End Sub
Private Sub jp_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jp.KeyPress
If Asc(e.KeyChar) = 13 Then
ttagihan.Text = Val(bbeban.Text) + (harga.Text * jp.Text)
pajak.Text = 0.01 * ttagihan.Text
pembayaran.Text = Val(ttagihan.Text) + Val(pajak.Text)
End If
End Sub
Private Sub kp_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kp.SelectedIndexChanged
Dim x As String
x = Microsoft.VisualBasic.Right(kp.Text, 3)
Select Case x
Case "100" : nama.Text = "Suhairy Tri Yadhi"
Case "101" : nama.Text = "Paul Walker"
Case "102" : nama.Text = "Dominic Toretto"
Case "103" : nama.Text = "Brian Haner"
Case "104" : nama.Text = "Lukman Wijaya"
End Select
x = Microsoft.VisualBasic.Left(kp.Text, 3)
Select Case x
Case "TOK"
harga.Text = 250
bbeban.Text = 15000
tipe.Text = "TOKO"
Case "RUM"
harga.Text = 150
bbeban.Text = 10000
tipe.Text = "RUMAH"
Case "PAB"
harga.Text = 25000
bbeban.Text = 250000
tipe.Text = "PABRIK"
Case "SWA"
harga.Text = 20000
bbeban.Text = 60000
tipe.Text = "SWALAYAN"
Case "SAL"
harga.Text = 900
bbeban.Text = 20000
tipe.Text = "SALON"
Case "GRO"
harga.Text = 100
bbeban.Text = 1100
tipe.Text = "GROSIR"
End Select
x = Microsoft.VisualBasic.Mid(kp.Text, 5, 3)
Select Case x
Case "MED"
: daerah.Text = "MEDAN"
Case "BEL"
: daerah.Text = "BELAWAN"
Case Else
: daerah.Text = "DELI SERDANG"
End Select
End Sub
Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub btnkeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim tanya As String
tanya = MsgBox("Anda Yakin Ingin Keluar ?", MsgBoxStyle.Question + MsgBoxStyle.YesNo)
If tanya = vbYes Then
Me.Close()
Else
Exit Sub
End If
End Sub
Private Sub LV_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LV.SelectedIndexChanged
End Sub
Sub BuatTabel()
LV.Columns.Add("Kode Pelanggan", 20, HorizontalAlignment.Center)
LV.Columns.Add("Nama", 180, HorizontalAlignment.Center)
LV.Columns.Add("Tipe", 80, HorizontalAlignment.Center)
LV.Columns.Add("Daerah", 80, HorizontalAlignment.Center)
LV.Columns.Add("Harga M3", 100, HorizontalAlignment.Center)
LV.Columns.Add("Biaya Beban", 160, HorizontalAlignment.Center)
LV.Columns.Add("Jumlah Pemakaian", 120, HorizontalAlignment.Center)
LV.Columns.Add("Pajak", 150, HorizontalAlignment.Center)
LV.Columns.Add("Total Tagihan", 100, HorizontalAlignment.Center)
LV.Columns.Add("Pembayaran", 120, HorizontalAlignment.Center)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub IsiTabel()
Dim Lst As New ListViewItem
Lst.Text = nama.Text
Lst.SubItems.Add(kp.Text)
Lst.SubItems.Add(tipe.Text)
Lst.SubItems.Add(daerah.Text)
Lst.SubItems.Add(harga.Text)
Lst.SubItems.Add(bbeban.Text)
Lst.SubItems.Add(jp.Text)
Lst.SubItems.Add(pajak.Text)
Lst.SubItems.Add(nama.Text)
LV.Items.Add(Lst)
End Sub
Private Sub btnproses_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnproses.Click
IsiTabel()
nama.Text = ""
kp.Text = ""
tipe.Text = ""
daerah.Text = ""
harga.Text = ""
bbeban.Text = ""
jp.Text = ""
pajak.Text = ""
ttagihan.Text = ""
pembayaran.Text = ""
End Sub
Private Sub btnhapus_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub btnhapussemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapussemua.Click
LV.Items.Clear()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End
End Sub
Private Sub btnberhis_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnberhis.Click
kp.Text = ""
nama.Text = ""
tipe.Text = ""
harga.Text = ""
jp.Text = ""
ttagihan.Text = ""
pembayaran.Text = ""
daerah.Text = ""
bbeban.Text = ""
pajak.Text = ""
End Sub
End Class
Tekan F5 untuk menjalankan tugas
jika tehah selesai maka tampilannya akan seperti ini
Demikilahlah postingan saya Nama : lukman wijaya NPM : 12110631selamat belajar bahasa pemograman dan jangan lupa kunjungi blog pak mesran
0 komentar:
Posting Komentar