Pages

Pages - Menu

Wednesday, May 11, 2016

Program Visual Basic Net Mengedit Data Yang Di Listview

Ini merupakan lanjutan dari postingan Program Visual Basic Net Menghitung Total Nilai Penjualan Pada Isi Listview.

Design form 
Program Visual Basic Net Mengedit Data Yang Di Listview berikut  :

Program Visual Basic Net Mengedit Data Yang Di Listview
Ketikkan listing Program Visual Basic Net Mengedit Data Yang Di Listview :

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i = 1 To 5
            Kode.Items.Add("P-00" & i)
            Jumlah.Items.Add(i)
        Next

        With LV
            .Columns.Add("Kode", 50, HorizontalAlignment.Center)
            .Columns.Add("Nama", 250, HorizontalAlignment.Left)
            .Columns.Add("Harga", 50, HorizontalAlignment.Right)
            .Columns.Add("Jumlah", 50, HorizontalAlignment.Center)
            .Columns.Add("Total Harga", 100, HorizontalAlignment.Right)
            .View = View.Details
            .GridLines = True
            .FullRowSelect = True
        End With
    End Sub

    Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode.SelectedIndexChanged
        Select Case Kode.Text
            Case "P-001"
                Nama.Text = "Televisi Sony 21 Inchi"
                Harga.Text = 2100000
            Case "P-002"
                Nama.Text = "Televisi Sony 14 Inchi"
                Harga.Text = 1900000
            Case "P-003"
                Nama.Text = "Televisi Sony 29 Inchi"
                Harga.Text = 2900000
            Case "P-004"
                Nama.Text = "Televisi Sony 32 Inchi"
                Harga.Text = 3500000
            Case "P-005"
                Nama.Text = "Televisi Sony 40 Inchi"
                Harga.Text = 4500000
            Case Else
                Nama.Text = ""
                Harga.Text = 0
        End Select
    End Sub

    Private Sub Jumlah_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Jumlah.SelectedIndexChanged
        Total.Text = Harga.Text * Jumlah.Text
    End Sub

   
    Private Sub BtnIsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnIsi.Click
        Dim xTP As Double = 0
        Dim lst As New ListViewItem
        lst.Text = Kode.Text
        lst.SubItems.Add(Nama.Text)
        lst.SubItems.Add(Harga.Text)
        lst.SubItems.Add(Jumlah.Text)
        lst.SubItems.Add(Total.Text)
        LV.Items.Add(lst)

        For i = 0 To LV.Items.Count - 1
            xTP = xTP + LV.Items(i).SubItems(4).Text
        Next
        TotalPenjualan.Text = xTP

        Kode.Text = ""
        Nama.Text = ""
        Harga.Text = ""
        Jumlah.Text = ""
        Total.Text = ""
    End Sub

    Private Sub BtnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnKeluar.Click
        End
    End Sub

    Private Sub LV_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LV.Click
        Kode.Text = LV.SelectedItems(0).SubItems(0).Text
        Nama.Text = LV.SelectedItems(0).SubItems(1).Text
        Harga.Text = LV.SelectedItems(0).SubItems(2).Text
        Jumlah.Text = LV.SelectedItems(0).SubItems(3).Text
        Total.Text = LV.SelectedItems(0).SubItems(4).Text
    End Sub

    
    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        Dim xTP As Double = 0
        LV.SelectedItems(0).SubItems(0).Text = Kode.Text
        LV.SelectedItems(0).SubItems(1).Text = Nama.Text
        LV.SelectedItems(0).SubItems(2).Text = Harga.Text
        LV.SelectedItems(0).SubItems(3).Text = Jumlah.Text
        LV.SelectedItems(0).SubItems(4).Text = Total.Text

        For i = 0 To LV.Items.Count - 1
            xTP = xTP + LV.Items(i).SubItems(4).Text
        Next
        TotalPenjualan.Text = xTP
    End Sub
End Class

Hasilnnya Program Visual Basic Net Mengedit Data Yang Di Listview akan nampak seperti berikut ini :

Program Visual Basic Net Mengedit Data Yang Di Listview

Tag : Program Visual Basic Net Mengedit Data Yang Di Listview, pemrograman vb net, program vb net, program vb net listview, belajar vb net


Bila bermanfaat silahkan share Program Visual Basic Net Mengedit Data Yang Di Listview ini dengan teman anda, Terima kasih sebelumnya


Sumber : Mesran.Net 
Link : http://mesran.net/berita-701-program-visual-basic-net-mengedit-data-yang-di-listview.html

0 comments:

Post a Comment