Yuk! Belajar Pemrograman Visual Basic dot Net Di Mesran.Net

Latihan Listview Perhitungan Penjualan Barang

Public Class Form1
   Sub buattable()
       lv.Columns.Add("No. Pembelian", 80, HorizontalAlignment.Center)
       lv.Columns.Add("Kode Barang", 80, HorizontalAlignment.Center)
       lv.Columns.Add("Nama Barang", 120, HorizontalAlignment.Center)
       lv.Columns.Add("Merk", 80, HorizontalAlignment.Center)
       lv.Columns.Add("Total Harga", 120, HorizontalAlignment.Center)
       lv.Columns.Add("Jumlah Beli", 120, HorizontalAlignment.Center)
       lv.Columns.Add("Harga", 120, HorizontalAlignment.Center)


       lv.View = View.Details
       lv.GridLines = True
       lv.FullRowSelect = True
   End Sub
   Sub isitable()
       Dim isi As New ListViewItem
       isi.Text = no.Text
       isi.SubItems.Add(Kbarang.Text)
       isi.SubItems.Add(Namabarang.Text)
       isi.SubItems.Add(Merk.Text)
       isi.SubItems.Add(Tharga.Text)
       isi.SubItems.Add(Jbeli.Text)
       isi.SubItems.Add(Harga.Text)
       lv.Items.Add(isi)


   End Sub
   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


       Namabarang.Text = ""
       Merk.Text = ""
       Kbarang.Items.Add("TS001")
       Kbarang.Items.Add("TS002")
       Kbarang.Items.Add("VG001")
       Kbarang.Items.Add("VG002")


       Call buattable()
       For i = 12 To 48 Step -1


       Next
   End Sub


   Private Sub Kbarang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kbarang.SelectedIndexChanged
       If Kbarang.Text = " TS001" Then
           Namabarang.Text = "Flashdisk 4GB"
           Merk.Text = "Toshiba"
       ElseIf Kbarang.Text = "TS002" Then
           Namabarang.Text = "Flashdisk 2GB"
           Merk.Text = "Toshiba"
       ElseIf Kbarang.Text = "VG001" Then
           Namabarang.Text = "Flashdisk 4GB"
           Merk.Text = "V-Gen"
       ElseIf Kbarang.Text = "VG002" Then
           Namabarang.Text = "Flashdisk 2GB"
           Merk.Text = "V-Gen"
       Else
           Namabarang.Text = "Flashdisk 4GB"
           Merk.Text = "Toshiba"


       End If
   End Sub


   Private Sub Btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnbersih.Click
       Tharga.Text = Val(Harga.Text) * Val(Jbeli.Text)


   End Sub


   Private Sub Btnsimpankelistview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsimpankelistview.Click
       Call isitable()
       no.Text = ""
       Kbarang.Text = ""
       Namabarang.Text = ""
       Merk.Text = ""
       Harga.Text = ""
       Jbeli.Text = ""
       Tharga.Text = ""


   End Sub


   Private Sub Btnhapussemuadata_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapussemuadata.Click
       no.Text = ""
       Kbarang.Text = ""
       Namabarang.Text = ""
       Merk.Text = ""
       Tharga.Text = ""
       Harga.Text = ""
       Jbeli.Text = ""
       Tharga.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 Btnhapusdatayangdisimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapusdatayangdisimpan.Click
       lv.Items.Remove(lv.SelectedItems(0))
   End Sub

End Class


Tampilan Form Hasil


NAMA : Abdul Wahab N
NPM : 13110407

Ingin belajar lebih dalam program kunjungi web ini www.mesran.net



Previous
Next Post »