Selesaikanlah Kasus Berikut :
Kasus Pemrograman Pemakaian Listrik
Private Sub ID_KeyPress (ByVal
sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles
KODE.KeyPress
Dim
TOMBOL As Integer = Asc(e.KeyChar)
If
TOMBOL = 13 Then
PROSES_Click(sender, e)
End If
End Sub
Private Sub ID_TextChanged(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles KODE.TextChanged
Dim x As
String
NO.Text
= "1" & Microsoft.VisualBasic.Right(KODE.Text, 2)
x =
Microsoft.VisualBasic.Mid(KODE.Text, 4, 3)
If x =
"MED" Then
DAERAH.Text = "MEDAN"
PAJAK.Text = 0.015
ElseIf x = "BEL" Then
DAERAH.Text = "BELAWAN"
PAJAK.Text = 0.015
ElseIf x = "TEM" Then
DAERAH.Text = "AKSARA"
PAJAK.Text = 0.015
ElseIf x = "MAR" Then
DAERAH.Text = "MARENDAL"
PAJAK.Text = 0.015
ElseIf x = "BIN" Then
DAERAH.Text = "BINJAI"
PAJAK.Text = 0.015
ElseIf x = "PAK" Then
DAERAH.Text = "LUBUK PAKAM"
PAJAK.Text = 0.015
End If
x =
Microsoft.VisualBasic.Mid(KODE.Text, 1, 3)
If x =
"TOK" Then
TIPE.Text = "TOKO"
HARGA.Text = "500"
BEBAN.Text = "150000"
ElseIf x = "RUM" Then
TIPE.Text = "RUMAH"
HARGA.Text = "200"
BEBAN.Text = "50000"
ElseIf x = "SWA" Then
TIPE.Text = "SWALAYAN"
HARGA.Text = "1500"
BEBAN.Text = "400000"
ElseIf x = "PAB" Then
TIPE.Text = "PABRIK"
BEBAN.Text = "1000000"
HARGA.Text = "10000"
End If
End Sub
Private Sub PROSES_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles PROSES.Click
BESAR.Text = SEKARANG.Text -
LALU.Text
TAGIHAN.Text = BEBAN.Text +
(HARGA.Text * BESAR.Text)
TOTAL.Text = TAGIHAN.Text * 0.015
End Sub
Sub buattabel()
LV.Columns.Add("TANGGAL
BAYAR", 80, HorizontalAlignment.Left)
LV.Columns.Add("NO. URUT",
80, HorizontalAlignment.Center)
LV.Columns.Add("KODE
PELANGGAN", 80, HorizontalAlignment.Left)
LV.Columns.Add("DAERAH",
80, HorizontalAlignment.Left)
LV.Columns.Add("TIPE
PELANGGAN", 80, HorizontalAlignment.Left)
LV.Columns.Add("BEBAN",
80, HorizontalAlignment.Left)
LV.Columns.Add("METERAN BULAN
LALU", 80, HorizontalAlignment.Left)
LV.Columns.Add("METERAN BULAN
SEKARANG", 80, HorizontalAlignment.Left)
LV.Columns.Add("HARGA PER
KWH", 80, HorizontalAlignment.Left)
LV.Columns.Add("BESAR
PEMAKAIAN", 80, HorizontalAlignment.Left)
LV.Columns.Add("PAJAK",
80, HorizontalAlignment.Left)
LV.Columns.Add("TAGIHAN",
80, HorizontalAlignment.Left)
LV.Columns.Add("TOTAL
BAYAR", 80, HorizontalAlignment.Left)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub isitabel()
Dim lst As New ListViewItem
lst.Text = TGL.Text
lst.SubItems.Add(NO.Text)
lst.SubItems.Add(KODE.Text)
lst.SubItems.Add(DAERAH.Text)
lst.SubItems.Add(TIPE.Text)
lst.SubItems.Add(BEBAN.Text)
lst.SubItems.Add(LALU.Text)
lst.SubItems.Add(SEKARANG.Text)
lst.SubItems.Add(HARGA.Text)
lst.SubItems.Add(BESAR.Text)
lst.SubItems.Add(PAJAK.Text)
lst.SubItems.Add(TAGIHAN.Text)
lst.SubItems.Add(TOTAL.Text)
LV.Items.Add(lst)
End Sub
Private Sub Form1_Load(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
buattabel()
Private Sub SIMPAN_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles SIMPAN.Click
isitabel()
KODE.Text = ""
DAERAH.Text = ""
BEBAN.Text = ""
TIPE.Text = ""
LALU.Text = ""
HARGA.Text = ""
TOTAL.Text = ""
SEKARANG.Text = ""
NO.Text
= ""
TAGIHAN.Text = ""
BESAR.Text = ""
PAJAK.Text = ""
End Sub
Private Sub HAPUS_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles HAPUS.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub RESET_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles RESET.Click
KODE.Text = ""
DAERAH.Text = ""
BEBAN.Text = ""
TIPE.Text = ""
LALU.Text = ""
HARGA.Text = ""
TOTAL.Text = ""
SEKARANG.Text = ""
NO.Text
= ""
TAGIHAN.Text = ""
BESAR.Text = ""
PAJAK.Text = ""
End Sub
Demikilahlah postingan saya
Nama : SRI KARTIKA SARI
NPM : 13110027
Selamat Belajar Pemrograman VB NET