Latest Games :
Home » » Yuk! Belajar Konsep Pemrograman Di Mesran.Blogspot.Com

Yuk! Belajar Konsep Pemrograman Di Mesran.Blogspot.Com

Sunday, June 2, 2013 | 0 komentar

Selesaikanlah Kasus Berikut :


Buatlah program untuk menampilkan hasil ke listview untuk kasus 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
        Me.Text = "PENJUALAN BARANG"

        Kode.Items.Add("TS001")
        Kode.Items.Add("TS002")
        Kode.Items.Add("VG001")
        Kode.Items.Add("VG002")

        Buattabel()
    End Sub
    Sub Buattabel()
        LV.Columns.Add("No Pembelian", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Kode Barang", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Nama Barang", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Merk", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Harga", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Jumlah Beli", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Total Harga", 80, HorizontalAlignment.Center)
        LV.View = View.Details
        LV.GridLines = True
        LV.FullRowSelect = True
    End Sub
    Sub ISITABEL()
        Dim LST As New ListViewItem
        LST.Text = No.Text
        LST.SubItems.Add(Kode.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
    Sub smpn(ByVal t As Form)
        No.Text = ""
        Kode.Text = ""
        Nama.Text = ""
        Merk.Text = ""
        Harga.Text = ""
        Jumlah.Text = ""
        Total.Text = ""
    End Sub

    Private Sub Kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kode.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(Kode.Text, 2)
        Select Case x
            Case "TS" : Merk.Text = "Toshiba"
            Case "VG" : Merk.Text = "V-Gen"
        End Select
        Dim y As String
        y = Microsoft.VisualBasic.Right(Kode.Text, 3)
        Select Case y
            Case "001" : Nama.Text = "Flashdisk 4GB"
            Case "002" : Nama.Text = "Flashdisk 2GB"
        End Select
        Dim z As String
        z = Microsoft.VisualBasic.Mid(Kode.Text, 1)
        Select Case z
            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 Btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnproses.Click
        Total.Text = Val(Harga.Text) * Val(Jumlah.Text)
    End Sub
    Private Sub Bntsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bntsimpan.Click
        ISITABEL()
        smpn(Me)
    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 Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.Click
        LV.Items.Clear()
    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 btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
        No.Text = ""
        Kode.Text = ""
        Nama.Text = ""
        Merk.Text = ""
        Harga.Text = ""
        Jumlah.Text = ""
        Total.Text = ""
    End Sub
End Class


Share this article :

No comments:

Post a Comment

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Informasi Dunia Maya - All Rights Reserved
Template Modify by Creating Website
Proudly powered by Blogger