Pertemuan 6 Perulangan(Looping)



Contoh Program mengitung penjualan barang 


Gambar 1.1 Desain Program


Kode Program

Public Class Form3
    Dim A As Integer

    Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CboKode.Items.Add("H001")
        CboKode.Items.Add("H002")
        CboKode.Items.Add("Y001")
        CboKode.Items.Add("Y002")
    End Sub

    Private Sub BtnCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCari.Click
        If CboKode.Text = "H001" Then
            TxtMerk.Text = "Honda"
            TxtType.Text = "Supra Fit"
            TxtSatuan.Text = 9000000
        ElseIf CboKode.Text = "H002" Then
            TxtMerk.Text = "Honda"
            TxtType.Text = "Supra X"
            TxtSatuan.Text = 11000000
        ElseIf CboKode.Text = "Y001" Then
            TxtMerk.Text = "Yamaha"
            TxtType.Text = "Mio"
            TxtSatuan.Text = 13000000
        Else
            TxtMerk.Text = "Yamaha"
            TxtType.Text = "Jupiter"
            TxtSatuan.Text = 12000000
        End If
    End Sub

    Private Sub BtnHitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnHitung.Click
        TxtTotal.Text = TxtJumlah.Text * TxtSatuan.Text
        If TxtType.Text = "Supra Fit" And TxtJumlah.Text > 5 Then
            TxtDiskon.Text = 5 / 100 * TxtTotal.Text
        ElseIf TxtType.Text = "Mio" And TxtJumlah.Text > 5 Then
            TxtDiskon.Text = 10 / 100 * TxtTotal.Text
        Else
            TxtDiskon.Text = 0
        End If
        TxtBayar.Text = TxtTotal.Text - TxtDiskon.Text
    End Sub

    Private Sub BtnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSimpan.Click
        ListView1.Items.Add(TxtTransaksi.Text)
        ListView1.Items(A).SubItems.Add(CboKode.Text)
        ListView1.Items(A).SubItems.Add(TxtMerk.Text)
        ListView1.Items(A).SubItems.Add(TxtType.Text)
        ListView1.Items(A).SubItems.Add(TxtSatuan.Text)
        ListView1.Items(A).SubItems.Add(TxtJumlah.Text)
        ListView1.Items(A).SubItems.Add(TxtTotal.Text)
        ListView1.Items(A).SubItems.Add(TxtDiskon.Text)
        ListView1.Items(A).SubItems.Add(TxtBayar.Text)
        A = A + 1
    End Sub

    Private Sub BtnBersih_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBersih.Click
        TxtBayar.Text = ""
        TxtDiskon.Text = ""
        TxtJumlah.Text = ""
        TxtMerk.Text = ""
        TxtSatuan.Text = ""
        TxtTotal.Text = ""
        TxtTransaksi.Text = ""
        TxtType.Text = ""
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        End
    End Sub
End Class


Gamabar 1.2 Tampilan Cari




Gamabar 1.3 Hasil Proses




Gambar 1.4 Tampilan Simpan



Gambar 1.5 Tampilan Bersih













Komentar

Postingan populer dari blog ini

Menu Bar dan Main From

Exception Handling

Procedure, Function dan Module