Minggu, 07 Desember 2014

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



Judul Soal :  Kasus Pemrograman Pemakaian Listrik


Berikut Jawaban Program : 

Public Class Form1

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

        Call BUAT_TABLE()
    End Sub
    Sub BUAT_TABLE()
        Lv.GridLines = True
        Lv.View = View.Details
        Lv.FullRowSelect = True
        Lv.Columns.Add("Kode pelanggan")
        Lv.Columns.Add("daerah")
        Lv.Columns.Add("tipe")
        Lv.Columns.Add("Biaya beban")
        Lv.Columns.Add("Harga Kwh")
        Lv.Columns.Add("Meter Bulan Ini")
        Lv.Columns.Add("Meter Bulan lalu")
        Lv.Columns.Add("Besar Pemakaian")
        Lv.Columns.Add("Total Tagihan")
        Lv.Columns.Add("pajak")
        Lv.Columns.Add("Pembayaran")
    End Sub
    Private Sub no_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kode.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(kode.Text, 3)
        Select Case x
            Case "TOK" : Tipe.Text = "TOKO"
                hargaKWH.Text = "500"
                Bbiaya.Text = "150000"
            Case "RUM" : Tipe.Text = "RUMAH"
                hargaKWH.Text = "200"
                Bbiaya.Text = "50000"
            Case "SWA" : Tipe.Text = "SWALAYAN"
                hargaKWH.Text = "1500"
                Bbiaya.Text = "400000"
            Case "PAB" : Tipe.Text = "PABRIK"
                hargaKWH.Text = "10000"
                Bbiaya.Text = "1000000"
        End Select
        x = Microsoft.VisualBasic.Mid(kode.Text, 5, 3)
        If x = "MED" Then
            daerah.Text = "MEDAN"
        ElseIf x = "BEL" Then
            daerah.Text = "BELAWAN"
        ElseIf x = "TEM" Then
            daerah.Text = "AKSARA"
        ElseIf x = "MAR" Then
            daerah.Text = "MARENDAL"
        ElseIf x = "BIN" Then
            daerah.Text = "BINJAI"
        Else
            daerah.Text = "LUBUK PAKAM"
        End If
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim lst As New ListViewItem
        lst.Text = kode.Text
        lst.SubItems.Add(daerah.Text)
        lst.SubItems.Add(tipe.Text)
        lst.SubItems.Add(Bbiaya.Text)
        lst.SubItems.Add(hargaKWH.Text)
        lst.SubItems.Add(MbulanI.Text)
        lst.SubItems.Add(MbulanL.Text)
        lst.SubItems.Add(Bpemakaian.Text)
        lst.SubItems.Add(Total.Text)
        lst.SubItems.Add(pajak.Text)
        lst.SubItems.Add(pembayaran.Text)
        lv.Items.Add(lst)
    End Sub

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

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        lv.Items.Remove(lv.SelectedItems(0))
    End Sub

    Private Sub Bpemakaian_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Bpemakaian.KeyPress
        If Asc(e.KeyChar) = 13 Then
            Total.Text = Val(Bbiaya.Text) + Val(hargaKWH.Text) * Bpemakaian.Text
            pajak.Text = 0.015 * Total.Text
            pembayaran.Text = Val(pajak.Text) + Val(Total.Text)
        End If
    End Sub

   
    Private Sub MbulanL_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MbulanL.TextChanged
        Bpemakaian.Text = Val(MbulanI.Text) - Val(MbulanL.Text)
    End Sub
End Class

Berikut Gambar Tampilan Hasil Program :

 


Demikianlah Postingan saya Nama : TONI SARTANA SIANTURI  NPM : 13110508

Selamat Belajar  Pemrograman VB NET
 

Tidak ada komentar:

Posting Komentar