Minggu, 02 Juni 2013

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

Latihan Listview Perhitungan Penjualan Barang

Public Class Form1

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

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

    End Sub

    Sub buattabel()
        LV.Columns.Add("NO.PEMBELIAN", 100, HorizontalAlignment.Center)
        LV.Columns.Add("KODE BARANG", 100, HorizontalAlignment.Center)
        LV.Columns.Add("NAMA BARANG", 100, HorizontalAlignment.Center)
        LV.Columns.Add("MERK", 100, HorizontalAlignment.Center)
        LV.Columns.Add("HARGA", 100, HorizontalAlignment.Center)
        LV.Columns.Add("JUMLAH BELI", 100, HorizontalAlignment.Center)
        LV.Columns.Add("TOTAL HARGA", 100, 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(KD.Text)
        Lst.SubItems.Add(NB.Text)
        Lst.SubItems.Add(MERK.Text)
        Lst.SubItems.Add(HARGA.Text)
        Lst.SubItems.Add(JB.Text)
        Lst.SubItems.Add(TH.Text)
        LV.Items.Add(Lst)
    End Sub

    Private Sub KD_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KD.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(KD.Text, 2)
        If x = "TS" Then
            MERK.Text = "TOSHIBA"
        ElseIf x = "VG" Then
            MERK.Text = "V-GEN"
        End If

        Dim y As String
        y = Microsoft.VisualBasic.Mid(KD.Text, 3)
        If y = "001" Then
            NB.Text = "FLASHDISK 4GB"
        ElseIf y = "002" Then
            NB.Text = "FLASHDISK 2GB"
        End If


        Dim z As String
        z = Microsoft.VisualBasic.Left(KD.Text, 5)
        If z = "TS001" Then
            HARGA.Text = "105000"
        ElseIf z = "TS002" Then
            HARGA.Text = "75000"
        ElseIf z = "VG001" Then
            HARGA.Text = "90000"
        ElseIf z = "VG002" Then
            HARGA.Text = "60000"
        End If
    End Sub

    Private Sub JB_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JB.TextChanged
        TH.Text = HARGA.Text * JB.Text
    End Sub
   

 Private Sub JB_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles JB.KeyPress
        Dim TOMBOL As Integer = Asc(e.KeyChar)
        If TOMBOL = 13 Then
            BTNSIMPAN_Click(sender, e)
        End If
    End Sub

    Private Sub BTNSIMPAN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSIMPAN.Click
        IsiTabel()
        NO.Text = " "
        KD.Text = " "
        NB.Text = " "
        MERK.Text = " "
        HARGA.Text = " "
        JB.Text = " "
        TH.Text = " "
    End Sub

    Private Sub BTNHAPSEM_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNHAPSEM.Click
        LV.Items.Clear()
    End Sub

    Private Sub BTNHAPDAT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNHAPDAT.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
        NO.Text = " "
        KD.Text = " "
        NB.Text = " "
        MERK.Text = " "
        HARGA.Text = " "
        JB.Text = " "
        TH.Text = " "
    End Sub

    Private Sub BTNKELUAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNKELUAR.Click
        End
    End Sub
End Class

HASIL TAMPILAN 


Demikilahlah postingan saya
Nama : FRISKA PRATIWI
NPM : 1111157
Selamat Pemrograman VB NET

Tidak ada komentar:

Poskan Komentar