Judul Soal: Latihan Listview Perhitungan Penjualan Barang
Berikut Jawaban Program:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
kb.Items.Add("TS001")
kb.Items.Add("TS002")
kb.Items.Add("VG001")
kb.Items.Add("VG002")
buattabel()
End Sub
Sub buattabel()
LV.Columns.Add("No.Pembeli", 80, HorizontalAlignment.Center)
LV.Columns.Add("Kode Barang", 180, HorizontalAlignment.Left)
LV.Columns.Add("Nama Barang", 180, HorizontalAlignment.Left)
LV.Columns.Add("merek", 180, HorizontalAlignment.Left)
LV.Columns.Add("Harga", 80, HorizontalAlignment.Left)
LV.Columns.Add("Jumlah Beli", 80, HorizontalAlignment.Left)
LV.Columns.Add("Total Harga", 80, HorizontalAlignment.Left)
LV.View = View.Details
LV.GridLines = True
LV.FullRowSelect = True
End Sub
Sub isitabel()
Dim lst As New ListViewItem
lst.Text = Np.Text
lst.SubItems.Add(kb.Text)
lst.SubItems.Add(nb.Text)
lst.SubItems.Add(merek.Text)
lst.SubItems.Add(harga.Text)
lst.SubItems.Add(jb.Text)
lst.SubItems.Add(th.Text)
LV.Items.Add(lst)
End Sub
Private Sub kb_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb.SelectedIndexChanged
Select Case kb.Text
Case "TS001" : nb.Text = "Flashdisk 4GB" : harga.Text = "105000"
Case "TS002" : nb.Text = "Flashdisk 2GB" : harga.Text = "75000"
Case "VG001" : nb.Text = "Flashdisk 4GB" : harga.Text = "90000"
Case "VG002" : nb.Text = "Flashdisk 2GB" : harga.Text = "60000"
End Select
End Sub
Private Sub nb_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nb.TextChanged
Select Case nb.Text
Case "Flashdisk 4GB" : merek.Text = "Toshiba"
Case "Flashdisk 2GB" : merek.Text = "Toshiba"
Case "Flashdisk 4GB" : merek.Text = "V-Gen"
Case "Flashdisk 2GB" : merek.Text = "V-Gen"
End Select
End Sub
Private Sub jb_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jb.KeyPress
If e.KeyChar = Chr(13) Then
th.Text = harga.Text * jb.Text
End If
End Sub
Private Sub jb_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jb.TextChanged
End Sub
Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
isitabel()
Np.Text = ""
kb.Text = ""
nb.Text = ""
merek.Text = ""
harga.Text = ""
jb.Text = ""
th.Text = ""
End Sub
Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
LV.Items.Clear()
End Sub
Private Sub btnhpusdata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhpusdata.Click
LV.Items.Remove(LV.SelectedItems(0))
End Sub
Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
Np.Text = ""
kb.Text = ""
nb.Text = ""
merek.Text = ""
harga.Text = ""
jb.Text = ""
th.Text = ""
End Sub
Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
Close()
End Sub
End Class
Demikianlah Postingan Saya
Nama: rafika-ulfa
Npm:1111229
Selamat
0 komentar:
Posting Komentar