Buatlah program untuk menampilkan hasil ke listview untuk kasus Latihan Listview Perhitungan Penjualan Barang
Form Design
Listing program
Public Class Form1
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Gol.Items.Add("IIIA")
Gol.Items.Add("IIIB")
Gol.Items.Add("IIIC")
End Sub
Private Sub Gol_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
Gol.SelectedIndexChanged
Select Case Gol.Text
Case
"IIIA" : Gaji.Text = 1500000
Case
"IIIB" : Gaji.Text = 2500000
Case
"IIIC" : Gaji.Text = 3500000
End Select
Pajak.Text = 0.15 * Gaji.Text
End Sub
Private Sub BtnProses_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnProses.Click
Gajiber.Text = Val(Gaji.Text) -
Val(Pinjaman.Text) - Val(Gajiber.Text)
End Sub
Private Sub BtnKeluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnKeluar.Click
Me.Close()
End Sub
Private Sub BtnHapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs)
End Sub
End Class
Hasil :
Public Class Form1
Sub
BuatTabel()
LV.Columns.Add("Pelanngan",
50, HorizontalAlignment.Center)
LV.Columns.Add("Tipe
pelanggan", 80, HorizontalAlignment.Center)
LV.Columns.Add("Biaya
beban", 120, HorizontalAlignment.Center)
LV.Columns.Add("Harga
per KWH", 120, HorizontalAlignment.Center)
LV.Columns.Add("Meter
bulan ini", 120, HorizontalAlignment.Center)
LV.Columns.Add("Meter
bulan lalu", 90, HorizontalAlignment.Center)
LV.Columns.Add("Jumlah
pemkaian", 50, HorizontalAlignment.Center)
LV.Columns.Add("Tagihan",
120, HorizontalAlignment.Center)
LV.Columns.Add("Pajak",
50, HorizontalAlignment.Center)
LV.Columns.Add("Total
tagihan", 120, 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 = Pelanggan.Text
Lst.SubItems.Add(Tipepel.Text)
Lst.SubItems.Add(Biaya.Text)
Lst.SubItems.Add(Harga.Text)
Lst.SubItems.Add(Meterbulanini.Text)
Lst.SubItems.Add(Meterbulanlalu.Text)
Lst.SubItems.Add(Jumlah.Text)
Lst.SubItems.Add(Tagihan.Text)
Lst.SubItems.Add(Pajak.Text)
Lst.SubItems.Add(Total.Text)
Lst.SubItems.Add(Pembayaran.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()
Pelanggan.Items.Add("MEDAN")
Pelanggan.Items.Add("BELAWAN")
Pelanggan.Items.Add("AKSARA")
Pelanggan.Items.Add("MRENDAL")
Pelanggan.Items.Add("BINJAI")
Pelanggan.Items.Add("LUBUK PAKAM")
Tipepel.Items.Add("TOKO")
Tipepel.Items.Add("RUMAH")
Tipepel.Items.Add("SWALAYAN")
Tipepel.Items.Add("PABRIK")
End Sub
Private Sub PAB_SelectedIndexChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
Tipepel.SelectedIndexChanged
Select Case Tipepel.Text
Case
"TOKO" : Biaya.Text = 150000
Case
"RUMAH" : Biaya.Text = 50000
Case
"SWALAYAN" : Biaya.Text = 400000
Case
"PABRIK" : Biaya.Text = 1000000
End Select
Select Case Tipepel.Text
Case
"TOKO" : Harga.Text = 500
Case
"RUMAH" : Harga.Text = 200
Case
"SWALAYAN" : Harga.Text = 1500
Case
"PABRIK" : Harga.Text = 10000
End Select
End Sub
Private Sub BtnProses_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnProses.Click
Total.Text = Val(Biaya.Text) +
Val(Harga.Text) * Val(Jumlah.Text)
End Sub
Private Sub BtnSimpan_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnSimpan.Click
IsiTabel()
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 BtnHapusdata_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnHapusdata.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub BtnKeluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnKeluar.Click
Me.Close()
End Sub
Private Sub Jumlah_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Jumlah.TextChanged
Jumlah.Text = Meterbulanini.Text -
Meterbulanlalu.Text
End Sub
End Class
0 komentar:
Posting Komentar