Senin, 15 Desember 2014

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

Tampilan Awal


Coding Nya:
Public Class Form1

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        kp.Text = ""
        np.Text = ""
        tipe.Text = ""
        daerah.Text = ""
        harga.Text = ""
        pemakaian.Text = ""
        totat.Text = ""
        pajak.Text = ""
        daerah.Text = ""
        pembayaran.Text = ""
        biba.Text = ""
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        kp.Items.Add("pab-pak-100")
        kp.Items.Add("pab-bel-100")
        kp.Items.Add("rum-bel-101")
        kp.Items.Add("swa-med-100")

        Call BuatTabel()
    End Sub

    Private Sub kp_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kp.SelectedIndexChanged
        Dim x As String
        x = Mid(kp.Text, 1, 3)
        Select x
            Case "TOK"
                tipe.Text = "toko"
                biba.Text = 150000
                harga.Text = 500
                np.Text = "santi"
            Case "rum"
                tipe.Text = "rumah"
                biba.Text = 50000
                harga.Text = 200
                np.Text = "angga"
            Case "swa"
                tipe.Text = "swalayan"
                biba.Text = 400000
                harga.Text = 1500
                np.Text = "sandi"
            Case "pab"
                tipe.Text = "pabrik"
                biba.Text = 1000000
                harga.Text = 10000
                np.Text = "roy"

        End Select
        x = Mid(kp.Text, 5, 3)
        Select Case x
            Case "med"
                daerah.Text = "medan"
            Case "bel"
                daerah.Text = "belawan"
            Case "tem"
                daerah.Text = "aksara"
            Case "mar"
                daerah.Text = "marendal"
            Case "bin"
                daerah.Text = "binjai"
            Case "pak"
                daerah.Text = "lubuk pakam"
        End Select
    End Sub

    Private Sub Proses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Proses.Click
        pajak.Text = 0.015 * totat.Text

        pembayaran.Text = Val(totat.Text) + Val(pajak.Text)
    End Sub
    Sub BuatTabel()
        LV.Columns.Add("Kode Pelanggan", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Nama Pelanggan", 180, HorizontalAlignment.Center)
        LV.Columns.Add("Tipe", 180, HorizontalAlignment.Center)
        LV.Columns.Add("Daerah", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Harga KWH", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Biaya Beban", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Pemakaian", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Total Tagihan", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Pajak", 80, HorizontalAlignment.Center)
        LV.Columns.Add("Pembayaran", 80, HorizontalAlignment.Center)
        LV.View = View.Details
        LV.GridLines = True
        LV.FullRowSelect = True
    End Sub
    Sub IsiTabel()
        Dim lst As New ListViewItem
        lst.Text = kp.Text
        lst.SubItems.Add(np.Text)
        lst.SubItems.Add(tipe.Text)
        lst.SubItems.Add(daerah.Text)
        lst.SubItems.Add(harga.Text)
        lst.SubItems.Add(biba.Text)
        lst.SubItems.Add(pemakaian.Text)
        lst.SubItems.Add(totat.Text)
        lst.SubItems.Add(pajak.Text)
        lst.SubItems.Add(pembayaran.Text)
        LV.Items.Add(lst)
    End Sub

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

    End Sub

    Private Sub H_list_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles H_list.Click
        Call IsiTabel()
    End Sub

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

    Private Sub pemakaian_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles pemakaian.KeyPress
        Dim a As String = Asc(e.KeyChar)
        If a = 13 Then
            totat.Text = (harga.Text * pemakaian.Text) + biba.Text
        End If
    End Sub

   

    Private Sub pemakaian_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pemakaian.TextChanged
       
    End Sub
End Class

Hasil:

0 komentar:

Posting Komentar