Senin, 15 Desember 2014

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

Selesaikanlah Kasus Berikut :
Kasus Pemrograman Pemakaian Listrik



Berikut Jawaban Program :

KODING :

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        kdpelanggan.Items.Add("PAB-PAK-100")
        kdpelanggan.Items.Add("PAB-MED-101")
        kdpelanggan.Items.Add("SWA-BEL-100")
        kdpelanggan.Items.Add("TOK-TEM-100")
        kdpelanggan.Items.Add("RUM-MAR-101")
        kdpelanggan.Items.Add("TOK-BIN-100")

        Call rancang_tabel()
    End Sub

    Private Sub kdpelanggan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kdpelanggan.SelectedIndexChanged
        If kdpelanggan.Text = "PAB-PAK-100" Then
            nama.Text = "IRWANSYAH"
        ElseIf kdpelanggan.Text = "PAB-MED-101" Then
            nama.Text = "IRWANSYAH PUTRA"
        ElseIf kdpelanggan.Text = "SWA-BEL-102" Then
            nama.Text = "TOMMY NUGRAHA"
        ElseIf kdpelanggan.Text = "TOK-TEM-100" Then
            nama.Text = "FATIH KARISMA"
        ElseIf kdpelanggan.Text = "RUM-MAR-101" Then
            nama.Text = "NOVITA ANANDA"
        ElseIf kdpelanggan.Text = "TOK-BIN-100" Then
            nama.Text = "SISKA AIRANGGA"
        End If

        Dim X As String
        X = Mid(kdpelanggan.Text, 1, 3)
        Select Case X
            Case "TOK"
                tipe.Text = "TOKO"
                byabbn.Text = 150000
                harga.Text = 500

            Case "RUM"
                tipe.Text = "RUMAH"
                byabbn.Text = 50000
                harga.Text = 200

            Case "SWA"
                tipe.Text = "SWALAYAN"
                byabbn.Text = 400000
                harga.Text = 1500

            Case "PAB"
                tipe.Text = "PABRIK"
                byabbn.Text = 1000000
                harga.Text = 10000
        End Select

        X = Mid(kdpelanggan.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 Buttonproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonproses.Click
        pemakaian.Text = blnini.Text - blnlalu.Text
        ttltagihan.Text = (Val(byabbn.Text) + Val(harga.Text)) * pemakaian.Text
        pajak.Text = 0.015 * ttltagihan.Text
        pmbyrn.Text = Val(ttltagihan.Text) + Val(pajak.Text)
    End Sub
    Sub rancang_tabel()
        LV.Columns.Add("Kode Pelanggan", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Nama", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Tipe Pelanggan", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Daerah", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Biaya Beban", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Harga per KWH", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Meter Bulan ini", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Meter Bulan Lalu", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Pemakaian", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Total Tagihan", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Pajak", 100, HorizontalAlignment.Center)
        LV.Columns.Add("Pembayaran", 100, HorizontalAlignment.Center)

        LV.GridLines = True
        LV.FullRowSelect = True
        LV.View = View.Details

    End Sub
    Sub isi_tabel()
        Dim X As New ListViewItem
        X.Text = kdpelanggan.Text
        X.SubItems.Add(nama.Text)
        X.SubItems.Add(tipe.Text)
        X.SubItems.Add(daerah.Text)
        X.SubItems.Add(byabbn.Text)
        X.SubItems.Add(harga.Text)
        X.SubItems.Add(blnini.Text)
        X.SubItems.Add(blnlalu.Text)
        X.SubItems.Add(pemakaian.Text)
        X.SubItems.Add(ttltagihan.Text)
        X.SubItems.Add(pajak.Text)
        X.SubItems.Add(pmbyrn.Text)

        LV.Items.Add(X)
    End Sub



   
    Private Sub LV_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LV.SelectedIndexChanged

    End Sub

    Private Sub Buttonhps_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonhps.Click
        kdpelanggan.Text = ""
        nama.Text = ""
        tipe.Text = ""
        daerah.Text = ""
        byabbn.Text = ""
        harga.Text = ""
        blnini.Text = ""
        blnlalu.Text = ""
        pemakaian.Text = ""
        ttltagihan.Text = ""
        pajak.Text = ""
        pmbyrn.Text = ""
    End Sub

    Private Sub Buttonsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonsimpan.Click
        Call isi_tabel()

    End Sub

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

    Private Sub Buttonhpssemua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonhpssemua.Click
        LV.Items.Clear()
    End Sub

    Private Sub btnkluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkluar.Click
        Me.Close()
    End Sub
End Class



HASIL :






Demikilahlah postingan saya
 Nama : Irwansyah Putra Manurung
 NPM : 13110383
Selamat Belajar Pemrograman VB NET

1 komentar:

  1. hahhaa,,, bingung di code gimana gan..??
    oke sipp.. (Y)

    BalasHapus