Rabu, 25 Maret 2020

Visual Lanjutan PRAKTEK 2 Kasus 4(NESTED IF)


Public Class kasus4
    'RAFIF KARUNIA RAHMAN 2017230174
    Dim sks, jumlah, tagihan, bayar, kembali 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 = ""
    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 ComboBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox2.KeyPress
        If ComboBox1.Text = "Reguler" Then
            If ComboBox2.Text = "Akuntansi" Then
                sks = 450000
            ElseIf ComboBox2.Text = "Manajemen" Then
                sks = 400000
            ElseIf ComboBox2.Text = "Teknik Informatika" Then
                sks = 350000
            ElseIf ComboBox2.Text = "Sistem Informasi" Then
                sks = 330000
            End If
        ElseIf ComboBox1.Text = "Karyawan" Then
            If ComboBox2.Text = "Akuntansi" Then
                sks = 500000
            ElseIf ComboBox2.Text = "Manajemen" Then
                sks = 450000
            ElseIf ComboBox2.Text = "Teknik Informatika" Then
                sks = 400000
            ElseIf ComboBox2.Text = "Sistem Informasi" Then
                sks = 380000
            End If
        End If
        TextBox3.Text = sks
    End Sub
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If (e.KeyChar = Chr(13)) Then
            TextBox2.Focus()
        End If
    End Sub
    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.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 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
            TextBox4.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
            sks = TextBox3.Text
            jumlah = TextBox4.Text
            TextBox5.Text = sks * jumlah
            TextBox5.Focus()
        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
            tagihan = TextBox5.Text
            bayar = TextBox6.Text
            TextBox7.Text = bayar - tagihan
            TextBox7.Focus()
        End If
    End Sub

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

    End Sub
End Class

Tidak ada komentar:

Posting Komentar