Rabu, 25 Maret 2020

Visual Lanjutan PRAKTEK 2 Kasus 11(SWITCH CASE)


Public Class kasus11
'RAFIF KARUNIA RAHMAN
    Dim merk, ukuran As String
    Dim harga, jumlah, subtotal, diskon, tagihan, bayar, kembali As Integer
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        Dim keyascii As Short = Asc(e.KeyChar)
        If (e.KeyChar Like "[A-Z,a-z]" _
            OrElse keyascii = Keys.Back _
            OrElse keyascii = Keys.Space _
            OrElse keyascii = Keys.Return _
            OrElse keyascii = Keys.Delete _
            ) Then
            keyascii = 0
        End If
        If (e.KeyChar = Chr(13)) Then
            ComboBox1.Focus()
        End If
        e.Handled = CBool(keyascii)
    End Sub
    Private Sub ComboBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox2.KeyPress
        Select Case ComboBox1.Text + ComboBox2.Text
            Case "IMP" + "XL"
                TextBox2.Text = 250000
            Case "IMP" + "L"
                TextBox2.Text = 240000
            Case "IMP" + "M"
                TextBox2.Text = 230000
            Case "Prada" + "XL"
                TextBox2.Text = 170000
            Case "Prada" + "L"
                TextBox2.Text = 160000
            Case "Prada" + "M"
                TextBox2.Text = 150000
            Case "Gucci" + "XL"
                TextBox2.Text = 280000
            Case "Gucci" + "L"
                TextBox2.Text = 270000
            Case "Gucci" + "M"
                TextBox2.Text = 260000
            Case "Loius" + "XL"
                TextBox2.Text = 360000
            Case "Loius" + "L"
                TextBox2.Text = 350000
            Case "Loius" + "M"
                TextBox2.Text = 340000
            Case "Denim" + "XL"
                TextBox2.Text = 130000
            Case "Denim" + "L"
                TextBox2.Text = 120000
            Case "Denim" + "M"
                TextBox2.Text = 110000
        End Select
        TextBox2.Focus()
    End Sub
    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True 'hanya bisa menginput angka
        If (e.KeyChar = Chr(13)) Then
            TextBox3.Focus()
        End If
    End Sub
    Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True 'hanya bisa menginput angka
        If (e.KeyChar = Chr(13)) Then
            harga = TextBox2.Text
            jumlah = TextBox3.Text
            TextBox4.Text = harga * jumlah
            TextBox4.Focus()
        End If
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        ComboBox1.Text = ""
        ComboBox2.Text = ""
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim pesan As String
        pesan = MsgBox("Yakin Ingin Keluar??", vbYesNo, "Konfirmasi")
        If pesan = vbYes Then
            End
        End If
    End Sub
    Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True 'hanya bisa menginput angka
        If (e.KeyChar = Chr(13)) Then
            subtotal = TextBox4.Text
            If subtotal >= 1000000 Then
                diskon = subtotal * (10 / 100)
            ElseIf subtotal >= 500000 And jumlah <= 1000000 Then
                diskon = subtotal * (7 / 100)
            ElseIf subtotal >= 200000 And jumlah <= 500000 Then
                diskon = subtotal * (4 / 100)
            Else
                diskon = 0
            End If
            TextBox5.Text = diskon
            TextBox5.Focus()
        End If
    End Sub
    Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True 'hanya bisa menginput angka
        If (e.KeyChar = Chr(13)) Then
            subtotal = TextBox4.Text
            diskon = TextBox5.Text
            tagihan = subtotal - diskon
            TextBox6.Focus()
        End If
        TextBox6.Text = tagihan
    End Sub
    Private Sub TextBox7_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox7.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True 'hanya bisa menginput angka
        If (e.KeyChar = Chr(13)) Then
            tagihan = TextBox6.Text
            bayar = TextBox7.Text
            TextBox8.Text = bayar - tagihan
        End If
    End Sub
    Private Sub TextBox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True 'hanya bisa menginput angka
        If (e.KeyChar = Chr(13)) Then
            TextBox7.Focus()
        End If
    End Sub

    Private Sub kasus11_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

Tidak ada komentar:

Posting Komentar