Sunday, 2 June 2013

Kasus Pemrograman Pemakaian Listrik



Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        daerah.Items.Add("Med")
        daerah.Items.Add("Bel")
        daerah.Items.Add("Mar")
        daerah.Items.Add("Bin")
        daerah.Items.Add("Pak")

        pelanggan.Items.Add("Toko")
        pelanggan.Items.Add("Rumah")
        pelanggan.Items.Add("Swalayan")
        pelanggan.Items.Add("Pabrik")

        nourut.Items.Add("100")
        nourut.Items.Add("200")
        nourut.Items.Add("300")
        nourut.Items.Add("400")

        buattabel()
    End Sub

    Private Sub pelanggan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pelanggan.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(pelanggan.Text, 3)
        Select Case x
            Case "Tok" : pemakaian.Text = 150000 + 500
            Case "Rum" : pemakaian.Text = 5000 + 200
            Case "Swa" : pemakaian.Text = 400000 + 1500
            Case "Pab" : pemakaian.Text = 1000000 + 10000
        End Select
       
    End Sub

    Private Sub daerah_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles daerah.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(daerah.Text, 3)
        Select Case x
            Case "Med" : daera.Text = "Medan"
            Case "Bel" : daera.Text = "Belawan"
            Case "Mar" : daera.Text = "Marelan"
            Case "Bin" : daera.Text = "Binjai"
            Case "Pak" : daera.Text = "Pakam"

        End Select
    End Sub

    Private Sub nourut_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nourut.SelectedIndexChanged
        Dim x As String
        x = Microsoft.VisualBasic.Left(nourut.Text, 3)
        Select Case x
            Case "100" : nama.Text = "Linsun"
            Case "200" : nama.Text = "Hamsiong"
            Case "300" : nama.Text = "Liing"
            Case "400" : nama.Text = "Osim"
        End Select
    End Sub

    Private Sub Bproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bproses.Click

        Total.Text = pemakaian.Text * 1.5
        isitabel()
    End Sub
    Sub buattabel()
        ListView1.Columns.Add("Kode Pelanggan", 80, HorizontalAlignment.Center)
        ListView1.Columns.Add("Daerah", 80, HorizontalAlignment.Center)
        ListView1.Columns.Add("Nama", 80, HorizontalAlignment.Center)
        ListView1.Columns.Add("No Urut", 80, HorizontalAlignment.Center)
        ListView1.Columns.Add("Pemakaian", 80, HorizontalAlignment.Center)
        ListView1.Columns.Add("Total Biaya", 80, HorizontalAlignment.Center)
        ListView1.View = View.Details
        ListView1.GridLines = True
        ListView1.FullRowSelect = True
    End Sub
    Sub isitabel()
        Dim x As New ListViewItem
        x.Text = daerah.Text
        x.SubItems.Add(pelanggan.Text)
        x.SubItems.Add(daera.Text)
        x.SubItems.Add(nourut.Text)
        x.SubItems.Add(nama.Text)
        x.SubItems.Add(pemakaian.Text)
        x.SubItems.Add(Total.Text)
        ListView1.Items.Add(x)
    End Sub

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

    Private Sub Bhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bhapus.Click
        ListView1.Items.Clear()
    End Sub
end class


Categories: ,

0 komentar:

Post a Comment