Langsung ke konten utama

Contoh Kasus Menggunakan IIF dan Select-Case pada VB.NET

Kasus 6 Menggunakan IIF


Berikut Source Code nya:

Public Class kasus6
    'nadiahtami 2017230007
    Dim hadir, tugas, uts, uas, akhir As Integer
    Dim grade, keterangan As String
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Application.Exit()
    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 = ""
    End Sub
    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.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
            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
    'nadiahtami2017230007
    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
            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
            TextBox6.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
            uas = TextBox6.Text
            uts = TextBox5.Text
            tugas = TextBox4.Text
            hadir = TextBox3.Text
            TextBox7.Text = (hadir * (20 / 100)) + (tugas * (25 / 100)) + (uts * (25 / 100)) + (uas * (30 / 100))
            TextBox7.Focus()
        End If
    End Sub
    Private Sub TextBox7_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox7.KeyPress
        akhir = TextBox7.Text
        grade = IIf(akhir >= 86 And akhir <= 100, "A", IIf(akhir >= 74 And akhir <= 85, "B",
            IIf(akhir >= 60 And akhir <= 73, "C", IIf(akhir >= 46 And akhir <= 59, "D", "E"))))
        TextBox8.Text = grade
        If (e.KeyChar = Chr(13)) Then
            TextBox8.Focus()
        End If
    End Sub

End Class

Kasus 7 Menggunakan IIF


Berikut Source Code nya :

Public Class kasus7
    Dim jabatan As String
    Dim gaji, tunjangan, total, potongan 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 = ""
        ComboBox1.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
    'nadiahtami 2017230007
    Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
        jabatan = ComboBox1.Text
        gaji = IIf(jabatan = "Manager", "5000000", IIf(jabatan = "Supervisor", "2500000", IIf(jabatan = "Operasional", "1000000", "0")))
            TextBox2.Text = gaji
            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
        gaji = TextBox2.Text
        If (e.KeyChar = Chr(13)) Then
            tunjangan = TextBox3.Text
            total = gaji + tunjangan
            TextBox4.Text = total
            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 = TextBox4.Text - 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
            TextBox5.Focus()
        End If
    End Sub

End Class

Kasus 8 Menggunakan Select Case


Berikut Source Code nya :

Public Class kasus8
    'nadiahtami 2017230007
    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
        If (e.KeyChar = Chr(13)) Then
            TextBox2.Focus()
        End If
    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 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 = ""
        TextBox9.Text = ""
        ComboBox1.Text = ""
    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
    'nadiahtami 2017230007
    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
            harga = TextBox3.Text
            jumlah = TextBox4.Text
            TextBox5.Text = harga * jumlah
            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 = TextBox5.Text
            jumlah = TextBox4.Text
            Select Case subtotal
                Case Is >= 100
                    diskon = subtotal * (10 / 100)
                Case 50 To 100
                    diskon = subtotal * (7 / 100)
                Case 20 To 50
                    diskon = subtotal * (4 / 100)
                Case Else
                    diskon = 0
            End Select
            TextBox6.Text = diskon
            TextBox6.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
            subtotal = TextBox5.Text
            diskon = TextBox6.Text
            tagihan = subtotal - diskon
            TextBox8.Focus()
        End If
        TextBox7.Text = tagihan
    End Sub
    Private Sub TextBox8_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox8.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
            bayar = TextBox8.Text
            diskon = TextBox6.Text
            kembali = bayar - tagihan
            TextBox9.Focus()
        End If
        TextBox9.Text = kembali
    End Sub
    Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
        Select ComboBox1.Text
            Case "Dus"
                TextBox3.Text = 100000
            Case "Box"
                TextBox3.Text = 30000
            Case "Botol"
                TextBox3.Text = 15000
            Case "Kaplet"
                TextBox3.Text = 5000
        End Select
    End Sub
End Class

Kasus 9 Menggunakan Select Case


Berikut Source Codenya :

Public Class kasus9
    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
    'nadiahtami 2017230007
    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

End Class

Kasus 10 Menggunakan Select Case


Berikut Source Codenya :

Public Class kasus10
    'nadiahtami 2017230007
    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
        Select Case ComboBox1.Text + ComboBox2.Text
            Case "Reguler" + "Akuntansi"
                TextBox3.Text = 450000
            Case "Reguler" + "Manajemen"
                TextBox3.Text = 400000
            Case "Reguler" + "Teknik Informatika"
                TextBox3.Text = 350000
            Case "Reguler" + "Sistem Informasi"
                TextBox3.Text = 330000
            Case "Karyawan" + "Akuntansi"
                TextBox3.Text = 500000
            Case "Karyawan" + "Manajemen"
                TextBox3.Text = 450000
            Case "Karyawan" + "Teknik Informatika"
                TextBox3.Text = 400000
            Case "Karyawan" + "Sistem Informasi"
                TextBox3.Text = 380000
        End Select
    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 TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
        If (e.KeyChar = Chr(13)) Then
            TextBox6.Focus()
        End If
    End Sub

End Class

Kasus 11 Menggunakan Select Case


Berikut Source Codenya :

Public Class kasus11
    Dim merk, ukuran As String
    Dim harga, jumlah, subtotal, diskon, tagihan, bayar, kembali As Integer
    'Nadiahtami 2017230007'
    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
End Class

Komentar

Postingan populer dari blog ini

Materi Percabangan Struktur IIF dan Struktur Select-Case

Percabangan (IIF)          Bentuk penulisan dari struktur If–Then–Else adalah tegak atau vertikal. Bentuk semacam ini tentu banyak memakan baris atau terulang panjang, apalagi jika bentuknya Nested If.        Untuk mengatasi kekurangan tersebut, dapat menggunakan struktur IIF yaitu struktur If–Then-else yang bentuknya datar atau horisontal. Bentuk penulisan IIF butuh variabel untuk menampung jawabannya. Dari segi kecepatan struktur IIF lebih cepat prosesnya dibandingkan dengan struktur If – Then – Else. Aturan Penulisannya adalah : 1. Expresi (kondisi)    Nilai = IIF (Ekspresi1, Nilai benar, Nilai Salah) 2. Lebih dari satu kondisi    Nilai = IIF (Ekspresi1, Nilai benar, IIF(Ekspresi1,Nilai benar, Nilai salah)) dan seterusnya... Keterangan : *kondisi: Berisi perbandingan antara satu variabel/konstanta dengan variabel/konstanta lain dengan menggunakan tanda <, >, =, <> dari suatu keadaan yang...

Variabel dan Tipe Data Visual Basic .NET

- Mengenal Variabel dan Tipe Data Visual Basic .NET - Deklarasi Variabel Variabel yakni objek yang dapat menerima pemasukan nilai-nilai tertentu. Dalam bahasa pemrograman fungsi variabel penting sekali untuk menampung nilai dan mengalokasikan untuk keperluan tertentu. Di Visual Basic .NET  cara untuk mendeklarasikan variabel sangat mudah, yakni dengan menggunakan perintah Dim. Contoh mendeklarasikan variabel di Visual Basic .NET yaitu: Dim NamaVariabel As tipe data Contoh: Dim Nama, Jurusan As String Dim Nilai As Int 'Pemberian Nilai pada Variabel' Nama =”Nadiah Tami” Jurusan =”Teknik Informatika” Nilai = 10 Kata Dim yakni kata yang digunakan untuk mendeklarasikan nama variabel. Ketika perintah Dim dieksekusi oleh compiler maka perintah Dim tersebut meminta tempat di memori untuk menyimpan data-data yang akan dialokasikan pada variabel tersebut.  Variabel Lokal dan Variabel Member Variabel Lokal yakni variabel yang dideklarasikan didalam prosedur atau event. ...

Materi tentang Array Multidimensi atau Dua Dimensi pada VB.NET

Array               Array adalah sekumpulan nilai dengan tipe data yang sama dan saling berhubungan satu sama lain. Nah kita bisa mengambil setiap nilai yang ada didalam array tersebut menggunakan sebuah angka yang disebut index untuk membedakannya. Terus didalam array juga ada yang disebut dengan “Element”, element sendiri adalah nilai-nilai yang ada didalam array tersebut. Array Multidimensi              Array multidimensi merupakan sebuah variabel yang menyimpan sekumpulan data yang memiliki type data sama dan elemen yang akan diakses melalui banyak indeks. Array bentuk ini biasanya digunakan untuk merepresentasikan nilai dari sebuah tabel. BentukUmum : Dim Array[indeks,Indeks] As Tipe_Data Dim Array[indeks,indeks,indeks] As Tipe_Data Contoh : Berikut Source Codenya : Public Class latihan4     'nadiahtami 2017230007'     Private Sub Button1_Click(ByVal sen...