Rabu, 25 Maret 2020

Visual Lanjutan PRAKTEK 2 Kasus 9(SELECT CASE)


Public Class kasus9
'RAFIF KARUNIA RAHMAN 2017230174
    Dim jabatan As String
    Dim gaji, tunjangan, total, potongan, anak, keluarga As Integer
    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 = ""
        ComboBox1.Text = ""
        ComboBox2.Text = ""
        ComboBox3.Text = ""
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Application.Exit()
    End Sub

    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
            TextBox3.Focus()
        End If
        e.Handled = CBool(keyascii)
    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
        gaji = TextBox2.Text
        If (e.KeyChar = Chr(13)) Then
            TextBox4.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
            TextBox6.Text = 25 / 100 * TextBox5.Text
            TextBox6.Focus()
        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
            tunjangan = TextBox3.Text
            total = gaji + tunjangan + keluarga
            TextBox5.Text = total
            TextBox5.Focus()
        End If
    End Sub
    Private Sub ComboBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox2.KeyPress
        jabatan = ComboBox2.Text
        Select Case jabatan
            Case Is = "Manager"
                gaji = 3000000
                tunjangan = 2000000
            Case Is = "Supervisor"
                gaji = 1500000
                tunjangan = 1000000
            Case Is = "Operasional"
                gaji = 1000000
                tunjangan = 500000
        End Select
        TextBox2.Text = gaji
        TextBox3.Text = tunjangan
        TextBox4.Focus()
    End Sub
    Private Sub ComboBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox3.KeyPress
        anak = ComboBox3.Text
        Select Case anak
            Case Is = 0
                keluarga = 100000
            Case Is = 1
                keluarga = 300000
            Case Is = 2
                keluarga = 500000
        End Select
        TextBox4.Text = keluarga
        TextBox4.Focus()
    End Sub
    Private Sub TextBox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress
        TextBox7.Text = TextBox5.Text - TextBox6.Text
    End Sub

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

    End Sub
End Class

Tidak ada komentar:

Posting Komentar