Minggu, 29 November 2015

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

 Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim i As Integer
        For i = 1 To 5
            no.Items.Add(i)
        Next
        kode.Items.Add("1")
        kode.Items.Add("2")
        kode.Items.Add("3")
        lv.Columns.Add("NO", 50, HorizontalAlignment.Center)
        lv.Columns.Add("Kode", 50, HorizontalAlignment.Center)
        lv.Columns.Add("Produk", 100, HorizontalAlignment.Center)
        lv.Columns.Add("Harga", 150, HorizontalAlignment.Left)
        lv.Columns.Add("Jumlah", 50, HorizontalAlignment.Center)
        lv.Columns.Add("Total", 150, HorizontalAlignment.Left)
        lv.View = View.Details
        lv.GridLines = True
        lv.FullRowSelect = True
    End Sub

    Private Sub kode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
        Select Case kode.Text
            Case "1"
                produk.Text = "TV"
                harga.Text = 2000000
            Case "2"
                produk.Text = "DVD"
                harga.Text = 650000
            Case "3"
                produk.Text = "CD-ROOM"
                harga.Text = 450000
        End Select
    End Sub

    Private Sub total_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles total.KeyPress
        If Asc(e.KeyChar) = 13 Then
            Call proses()
        End If
    End Sub
    Sub proses()
        total.Text = Val(harga.Text) * Val(jumlah.Text)
    End Sub
    Private Sub total_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles total.TextChanged

    End Sub

    Private Sub Btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnproses.Click
        Dim list As New ListViewItem
        list.Text = no.Text
        list.SubItems.Add(kode.Text)
        list.SubItems.Add(produk.Text)
        list.SubItems.Add(harga.Text)
        list.SubItems.Add(jumlah.Text)
        list.SubItems.Add(total.Text)
        lv.Items.Add(list)
    End Sub

    Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnhapus.Click
        no.Text = ""
        kode.Text = ""
        produk.Text = ""
        harga.Text = ""
        jumlah.Text = ""
        total.Text = ""
    End Sub

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

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

Tidak ada komentar:

Posting Komentar