Selasa, 10 November 2015

UTS - Penjualan Buku - Pemograman Visual






Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        JenisBuku.Items.Add("Novel")
        JenisBuku.Items.Add("Motivasi")
        JenisBuku.Items.Add("Sejarah")
        JenisBuku.Items.Add("Tokoh")

        Harga.ReadOnly = True
        Discount.ReadOnly = True
        TotalHarga.ReadOnly = True
        TotalBayar.ReadOnly = True
    End Sub

    Private Sub JenisBuku_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JenisBuku.SelectedIndexChanged
        Select Case JenisBuku.Text
            Case "Novel"
                Harga.Text = 135000
            Case "Motivasi"
                Harga.Text = 105000
            Case "Sejarah"
                Harga.Text = 140000
            Case Else
                Harga.Text = 133000
        End Select
    End Sub

    Private Sub Jumlah_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Jumlah.KeyPress

        Dim x, y As Integer

        If Asc(e.KeyChar) = 13 Then
            If Jumlah.Text = "" Or Harga.Text = "" Then
                JenisBuku.Focus()
            Else
                TotalHarga.Text = Val(Jumlah.Text) * Val(Harga.Text)
            End If

            If JenisBuku.Text = "Novel" Then
                x = 0.2 * TotalHarga.Text
            ElseIf JenisBuku.Text = "Motivasi" Then
                x = 0.05 * TotalHarga.Text
            ElseIf JenisBuku.Text = "Sejarag" Then
                x = 0.5 * TotalHarga.Text
            Else
                x = 0.15 * TotalHarga.Text
            End If

            If TotalHarga.Text >= 2000000 Then
                y = 0.1 * TotalHarga.Text
            Else
                y = 0
            End If

            Discount.Text = Val(x) + Val(y)

            TotalBayar.Text = Val(TotalHarga.Text) - Val(Discount.Text)
        End If
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        JenisBuku.Text = ""
        Harga.Text = ""
        Jumlah.Text = ""
        TotalHarga.Text = ""
        Discount.Text = ""
        TotalBayar.Text = ""
        JenisBuku.Focus()
    End Sub

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




Jumat, 09 Oktober 2015

Menampilkan Nilai ASCII + SIMBOL Menggunakan VB.Net 2008


Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i = 1 To 225
            ComboBOx1.Items.Add(i & "    =   " & Chr(i))
            ListBox1.Items.Add(i & "    =   " & Chr(i))
        Next

        For i = 90 To 65 Step -1
            ListBox2.Items.Add(i & "    =   " & Chr(i))
        Next

        For i = 97 To 122
            ListBox3.Items.Add(i & "    =   " & Chr(i))
        Next
    End Sub
End Class