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

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

 

SOAL 1Buatlah program untuk menampilkan hasil ke listview untuk kasus Latihan Listview Perhitungan Penjualan Barang

 

Listing 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")

        rancangtable()
    End Sub

    Private Sub kb_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kb.SelectedIndexChanged
        Dim x As String
        Dim y As String
        x = Microsoft.VisualBasic.Left(kb.Text, 2)
        Select Case x
            Case "TS" : merk.Text = "TOSHIBAH"
            Case "VG" : merk.Text = "V-Gen"
        End Select
        y = Microsoft.VisualBasic.Right(kb.Text, 3)
        Select Case y
            Case "001" : nb.Text = "Flashdisk 4GB"
            Case "002" : nb.Text = "Flashdisk 2GB"
        End Select
        If x = "TS" And y = "001" Then
            harga.Text = 105000
        ElseIf x = "TS" And y = "002" Then
            harga.Text = 75000
        ElseIf x = "VG" And y = "001" Then
            harga.Text = 90000
        Else
            harga.Text = 6000
        End If
    End Sub

    Private Sub jb_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jb.KeyPress
        th.Text = Val(harga.Text) * Val(jb.Text)
    End Sub

 
    Sub rancangtable()
        lv.Columns.Add("no.pembelian", 80, HorizontalAlignment.Center)
        lv.Columns.Add("kode barng", 80, HorizontalAlignment.Left)
        lv.Columns.Add("nama barang", 80, HorizontalAlignment.Center)
        lv.Columns.Add("merk", 80, HorizontalAlignment.Left)
        lv.Columns.Add("harga", 80, HorizontalAlignment.Center)
        lv.Columns.Add("jumlah beli", 80, HorizontalAlignment.Left)
        lv.Columns.Add("total harga", 80, HorizontalAlignment.Center)
        lv.View = View.Details
        lv.GridLines = True
        lv.FullRowSelect = True
    End Sub
    Sub isitable()
        Dim lst As New ListViewItem
        lst.Text = no_pembelian.Text
        lst.SubItems.Add(kb.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 bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bersih.Click
        no_pembelian.Text = ""
        kb.Text = ""
        nb.Text = ""
        merk.Text = ""
        harga.Text = ""
        jb.Text = ""
        th.Text = ""

    End Sub

 
    Private Sub hapus_semua_data_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_semua_data.Click
        lv.Items.Clear()

    End Sub

    Private Sub data_yang_di_pilih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles data_yang_di_pilih.Click
        lv.Items.Remove(lv.SelectedItems(0))

    End Sub

    Private Sub keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles keluar.Click
        Me.Close()

    End Sub

    Private Sub simpan_ke_listiew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan_ke_listiew.Click
        isitable()
    End Sub
End Class

 

Tampilan Hasilnya:

 

 

 
 

 

 

1 komentar:

  1. ♥♦♣♠ PELANGI QQ ♠♣♦♥
    Mari Bergabung bersama kami di PelangiKiuKiu (.) Net
    Situs Impian Para pecinta dan peminat Taruhan Online!!
    Segera Daftarkan diri Anda di PelangiQQ dan dapatkan Bonus yang sudah tersedia. Agen Poker Online Terpercaya dan Terbesar di Indonesia yang menggunakan Uang Asli.
    MINIMAL DEPOSIT & WITHDRAW Rp 25.000
    PelangiQQ Menyediakan 8 Permainan yang bisa di mainkan hanya dengan 1 User ID,yaitu:
    Bandar66 (NEW GAME)
    SAKONG
    Poker
    Domino99
    Capsa susun
    AduQ
    BandarQ
    Bandar Poker
    - SKYPE : PELANGIQQ
    - LINE : PELANGIQQ
    - FACEBOOK : PokerPelangiReborn
    - PIN BB : E37271BF
    - WhatssApp : 6281231804952
    Salam Sukses & Hoki

    BalasHapus