Minggu, 08 Desember 2013

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

Yuk! Belajar Pemrograman Visual Basic dot Net Di Mesran.Net
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        BuatTabel()

        kodebarang.Items.Add("hp001")
        kodebarang.Items.Add("hp002")
        kodebarang.Items.Add("VG001")
        kodebarang.Items.Add("VG002")
    End Sub

    Private Sub kodebarang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kodebarang.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(kodebarang.Text, 2)
        Select Case x
            Case "hp" : merk.Text = "handphone"
            Case "VG" : merk.Text = "V-Gen"
        End Select
        x = Microsoft.VisualBasic.Right(kodebarang.Text, 3)
        Select Case x
            Case "001" : namabarang.Text = "Flasdisk 36GB"
            Case "001" : namabarang.Text = "Flasdisk 2GB"

        End Select

        If kodebarang.Text = "hp001" Then
            harga.Text = "105000"
        ElseIf kodebarang.Text = "hp002" Then
            harga.Text = "75000"
        ElseIf kodebarang.Text = "VG001" Then
            harga.Text = "90000"
        ElseIf kodebarang.Text = "VG002" Then
            harga.Text = "60000"
        End If

    End Sub

    Private Sub jumlahbeli_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles jumlahbeli.KeyPress
        If Asc(e.KeyChar) = 13 Then
            total.Text = Val(harga.Text) * Val(jumlahbeli.Text)
        End If
    End Sub

    Private Sub jumlahbeli_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlahbeli.TextChanged

    End Sub

    Private Sub btnbersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbersih.Click
        no.Text = ""
        kodebarang.Text = ""
        namabarang.Text = ""
        merk.Text = ""
        harga.Text = ""
        jumlahbeli.Text = ""
        total.Text = ""
    End Sub
    Sub BuatTabel()
        LV.Columns.Add("No.Pembeli", 70, HorizontalAlignment.Center)
        LV.Columns.Add("Kode Barang", 120, HorizontalAlignment.Center)
        LV.Columns.Add("Nama Barang", 120, HorizontalAlignment.Left)
        LV.Columns.Add("Merk", 90, HorizontalAlignment.Left)
        LV.Columns.Add("Harga", 90, HorizontalAlignment.Center)
        LV.Columns.Add("Jumlah Beli", 90, HorizontalAlignment.Center)
        LV.Columns.Add("Total", 150, HorizontalAlignment.Left)
        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(kodebarang.Text)
        lst.SubItems.Add(namabarang.Text)
        lst.SubItems.Add(merk.Text)
        lst.SubItems.Add(harga.Text)
        lst.SubItems.Add(jumlahbeli.Text)
        lst.SubItems.Add(total.Text)
        LV.Items.Add(lst)

    End Sub

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click
        IsiTabel()
        no.Text = ""
        kodebarang.Text = ""
        namabarang.Text = ""
        merk.Text = ""
        harga.Text = ""
        jumlahbeli.Text = ""
        total.Text = ""
    End Sub

    Private Sub btnall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnall.Click
        LV.Items.Clear()

    End Sub

    Private Sub btnhapussatu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapussatu.Click
        LV.Items.Remove(LV.SelectedItems(0))
    End Sub

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

    End Sub

    Private Sub no_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles no.TextChanged

    End Sub

End Class

inilah hasilnya



Demikianlah postingan saya :
Nama : Annikmah Ritonga
NPM : 12110286

Tidak ada komentar:

Posting Komentar