Latihan Listview Perhitungan Penjualan Barang
Untuk mengolah isi data program di atas
Ini lah formnya :
Public Class Form1
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
BuatTabel()
kdbrg.Items.Add("TS001")
kdbrg.Items.Add("TS002")
kdbrg.Items.Add("VG001")
kdbrg.Items.Add("VG002")
End Sub
Sub
BuatTabel()
LV.Columns.Add("Kode",
80, HorizontalAlignment.Center)
LV.Columns.Add("Nama",
80, HorizontalAlignment.Left)
LV.Columns.Add("Merk",
85, HorizontalAlignment.Left)
LV.Columns.Add("Harga",
80, HorizontalAlignment.Left)
LV.Columns.Add("Jumlah",
80, HorizontalAlignment.Left)
LV.Columns.Add("Total",
80, HorizontalAlignment.Left)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub
IsiTabel()
Dim Lst
As New
ListViewItem
Lst.Text = kdbrg.Text
Lst.SubItems.Add(Nama.Text)
Lst.SubItems.Add(Merk.Text)
Lst.SubItems.Add(Harga.Text)
Lst.SubItems.Add(Jumlah.Text)
Lst.SubItems.Add(Total.Text)
LV.Items.Add(Lst)
End Sub
Private Sub kdbrg_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
kdbrg.SelectedIndexChanged
Dim X As String
Dim A As String
Dim H As String
X =
Microsoft.VisualBasic.Left(kdbrg.Text, 2)
A =
Microsoft.VisualBasic.Right(kdbrg.Text, 3)
H =
Microsoft.VisualBasic.Right(kdbrg.Text, 5)
Select Case X
Case
"TS" : Merk.Text = "Toshiba"
Case
"VG" : Merk.Text = "V-Gen"
End Select
Select Case A
Case
"001" : Nama.Text = "Flashdisk 4Gb"
Case
"002" : Nama.Text = "Flashdisk 2Gb"
End Select
Select Case H
Case
"TS001" : Harga.Text = "105000"
Case
"TS002" : Harga.Text = "75000"
Case
"VG001" : Harga.Text = "90000"
Case
"VG002" : Harga.Text = "60000"
End Select
End Sub
Private Sub Btnhapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btnhapus.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub Btnhapusdatagdipilih_Click(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
Btnhapusdatagdipilih.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 Btnsimpankelistview_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles
Btnsimpankelistview.Click
IsiTabel()
End Sub
Private Sub Jumlah_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
Jumlah.KeyPress
Dim
Tombol As Integer
= Asc(e.KeyChar)
If
Tombol = 13 Then
Jumlah_TextChanged(sender, e)
Total.Text = Jumlah.Text *
Harga.Text
End If
End Sub
Private Sub Jumlah_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Jumlah.TextChanged
End Sub
Private Sub Total_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Total.TextChanged
Dim
Tombol As Integer
Jumlah_TextChanged(sender, e)
Total.Text = Jumlah.Text * Harga.Text
End Sub
End Class
Tidak ada komentar:
Posting Komentar