Selamat Berkunjung

Kamis, 06 Juni 2013

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

Design Form:




Listing Program :


Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RancangTabel()
        kode_barang.Items.Add("TSF001")
        kode_barang.Items.Add("TSF002")
        kode_barang.Items.Add("VGR001")
        kode_barang.Items.Add("VGR002")
        kode_barang.Items.Add("VGR003")
        no_pembelian.Focus()
    End Sub
    Sub RancangTabel()
        lv.Columns.Add("No.Pembelian", 100, HorizontalAlignment.Center)
        lv.Columns.Add("Kode Barang", 80, HorizontalAlignment.Center)
        lv.Columns.Add("Nama Barang", 100, HorizontalAlignment.Center)
        lv.Columns.Add("Merek", 80, HorizontalAlignment.Center)
        lv.Columns.Add("Harga", 90, HorizontalAlignment.Center)
        lv.Columns.Add("Jumlah Beli", 50, HorizontalAlignment.Center)
        lv.Columns.Add("Total Harga", 80, HorizontalAlignment.Center)
        lv.GridLines = True
        lv.FullRowSelect = True
        lv.View = View.Details
    End Sub
    Sub hapus()
        no_pembelian.Text = ""
        kode_barang.Text = ""
        nama_barang.Text = ""
        merek.Text = ""
        harga.Text = ""
        jumlah_beli.Text = ""
        total.Text = ""
    End Sub
    Sub MasukTabel()
        Dim frendiks As New ListViewItem
        With frendiks
            .Text = no_pembelian.Text
            .SubItems.Add(kode_barang.Text)
            .SubItems.Add(nama_barang.Text)
            .SubItems.Add(merek.Text)
            .SubItems.Add(harga.Text)
            .SubItems.Add(jumlah_beli.Text)
            .SubItems.Add(total.Text)
            lv.Items.Add(frendiks)


        End With
    End Sub

    Private Sub lv_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lv.SelectedIndexChanged

    End Sub

    Private Sub kode_barang_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode_barang.SelectedIndexChanged

        Dim x As String
        Dim x2 As String
        x = Microsoft.VisualBasic.Mid(kode_barang.Text, 3, 1)
               x = Microsoft.VisualBasic.Left(kode_barang.Text, 2)
        If x = "TS" Then
            merek.Text = "TOSHIBA"
        ElseIf x = "VG" Then
            merek.Text = "V-Gen"
        End If


        x2 = Microsoft.VisualBasic.Right(kode_barang.Text, 3)
        If x2 = "001" Then
            nama_barang.Text = "Leptop"
        ElseIf x2 = "002" Then
            nama_barang.Text = "Flashdisk"
        End If

        If x = "TS" And x2 = "001" Then
            harga.Text = 105000
        ElseIf x = "TS" And x2 = "002" Then
            harga.Text = 75000
        ElseIf x = "VG" And x2 = "001" Then
            harga.Text = 90000
        ElseIf x = "VG" And x2 = "002" Then
            harga.Text = 60000
        Else
            harga.Text = 0
        End If
    End Sub

    Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label7.Click

    End Sub

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

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles jumlah_beli.TextChanged

    End Sub

    Private Sub simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles simpan.Click
        MasukTabel()
        hapus()
        no_pembelian.Focus()
    End Sub

    Private Sub bersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bersih.Click
        hapus()
        no_pembelian.Focus()
    End Sub

    Private Sub hapus_semua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_semua.Click
        If lv.SelectedItems.Count <> 0 Then
            lv.Items.Remove(lv.SelectedItems(0))
        Else
            MsgBox("Pilih yang akan dihapus")
        End If
    End Sub

    Private Sub hapus_satu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles hapus_satu.Click
        lv.Items.Clear()
    End Sub

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

Untuk lebih lengkap silahkan kunjungi mesran.net

1 komentar:

  1. LV.Columns.Add("No.", 80, HorizontalAlignment.Center)
    LV.Columns.Add("Kode", 80, HorizontalAlignment.Center)
    LV.Columns.Add("Nama", 100, HorizontalAlignment.Left)
    LV.Columns.Add("Merek", 90, HorizontalAlignment.Center)
    LV.Columns.Add("Harga", 80, HorizontalAlignment.Right)
    LV.Columns.Add("Jumlah", 50, HorizontalAlignment.Center)
    LV.Columns.Add("Total", 50, HorizontalAlignment.Right)
    LV.View = View.Details
    LV.GridLines = True
    LV.FullRowSelect = True

    Apa itu LV tolong dule

    BalasHapus