Selasa, 31 Maret 2020

Visual Lanjutan Rangkuman Praktikum 4


Array 2 Dimensi
·      Pengertian
Array adalah sekumpulan dari variabel atau nilai - nilai yang memilki tipe data dan nama yang sama dalam suatu urutan tertentu. Letak atau posisi sebuah elemen array di tentukan oleh index.
Array 1 Dimensi adalah kumpulan - kumpulan elemen yang memiliki type data yang sama dan hanya memiliki satu indeks saja. Array 1 Dimensi dapat berupa sebuah vector, contoh cara membuat sebuah array di VB.NET
·       Fungsi
Array memungkinkan kita untuk menyimpan data ataupun referensi objek dengan jumlah yang banyak dan terindeks. Indeks dalam array menggunakan integer, indeks ini digunakan untuk menentukan urutan dari elemen-elemennya, dan urutan indeks array biasanya dimulai dengan indeks nol (0) pada elemen pertama, kemudian indeks satu (1) untuk elemen kedua, dan seterusnya
·      Cara Mendeklarasikan
Mendeklarasikan variabel array dengan type data tertentu caranya hampir sama dengan mendeklarasikan variabel pada umumnya. Hanya saja pada pendeklarasian variabel array biasanya menggunakan tanda kurung yang diletakkan setelah nama array. Berikut ini contoh pendeklarasian variabel array pada vb.net:
Dim Var_Array(n) as Tipe data
Keterangan :
Dim keyword untuk memulai mendeklarasikan variabel. Var_Array adalah variabel array yang akan dibuat. (n) Jumlah penampung yang kita pesan dengan nilai integer. Tipe data tipe data dari sebuah Variabel array.
Contoh pendeklarasian array Dim mhs (4) as String Dengna perantah deklarasi di atas kita mendeklarasikan nama variabel mhs dengan jumlah tampugan data 5, karena di VB pendeklarsian tersebut berarti dari 0-4, berjumlah 5 tampungan.
·       Bentuk Array 1 Dimensi
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
Untuk dapat lebih memahami bagaimana pendeklarasian array dan indeksnya mari kita lihat beberapa contoh berikut ini:
Contoh 1
Dim arr(0, 1) As String
        arr(0, 0) = "NIS"
        arr(0, 1) = "Nama Siswa"
Contoh 2
Dim arr(1, 1) As String
        arr(0, 0) = "NIS"
        arr(0, 1) = "Nama Siswa"
        arr(1, 0) = "Jenis Kelamin"
        arr(1, 1) = "No. HP"
Contoh 3
Dim arr(1, 2) As String
         arr(0, 0) = "NIS"
         arr(0, 1) = "Nama Siswa"
         arr(0, 2) = "TTL"
         arr(1, 0) = "Jenis Kelamain"
 arr(1, 1) = "No. HP"
 arr(1, 2) = "Alamat"
Contoh 4
Dim arr(2, 2) As String
         arr(0, 0) = "NIS"
         arr(0, 1) = "Nama Siswa"
         arr(0, 2) = "TTL"
         arr(1, 0) = "Jenis Kelamain"
 arr(1, 1) = "No. HP"
 arr(1, 2) = "Alamat"
 arr(2, 0) = "Hoby"
 arr(2, 1) = "Cita-cita"
 arr(2, 2) = "Motto


Visual Lanjutan Rangkuman Teori 4


Array 1 Dimensi
·      Pengertian
Array adalah sekumpulan dari variabel atau nilai - nilai yang memilki tipe data dan nama yang sama dalam suatu urutan tertentu. Letak atau posisi sebuah elemen array di tentukan oleh index.
Array 1 Dimensi adalah kumpulan - kumpulan elemen yang memiliki type data yang sama dan hanya memiliki satu indeks saja. Array 1 Dimensi dapat berupa sebuah vector, contoh cara membuat sebuah array di VB.NET
·       Fungsi
Array memungkinkan kita untuk menyimpan data ataupun referensi objek dengan jumlah yang banyak dan terindeks. Indeks dalam array menggunakan integer, indeks ini digunakan untuk menentukan urutan dari elemen-elemennya, dan urutan indeks array biasanya dimulai dengan indeks nol (0) pada elemen pertama, kemudian indeks satu (1) untuk elemen kedua, dan seterusnya
·      Cara Mendeklarasikan
Mendeklarasikan variabel array dengan type data tertentu caranya hampir sama dengan mendeklarasikan variabel pada umumnya. Hanya saja pada pendeklarasian variabel array biasanya menggunakan tanda kurung yang diletakkan setelah nama array. Berikut ini contoh pendeklarasian variabel array pada vb.net:
Dim Var_Array(n) as Tipe data
Keterangan :
Dim keyword untuk memulai mendeklarasikan variabel. Var_Array adalah variabel array yang akan dibuat. (n) Jumlah penampung yang kita pesan dengan nilai integer. Tipe data tipe data dari sebuah Variabel array.
Contoh pendeklarasian array Dim mhs (4) as String Dengna perantah deklarasi di atas kita mendeklarasikan nama variabel mhs dengan jumlah tampugan data 5, karena di VB pendeklarsian tersebut berarti dari 0-4, berjumlah 5 tampungan.
·       Bentuk Array 1 Dimensi
Array satu dimensi adalah kumpulan elemen yang tersusun dalam suatu baris dengan tipe data yang sama. BentukUmum :
Dim Array[indeks] As Tipe_Data
Contoh : Dim Arr(2) As String
Arr(0) = Txtkodebarang.Text
Arr(1) = Txtnamabaramg.Text
Arr(2) = Txtjenisbarang.Text

Rabu, 25 Maret 2020

Visual Lanjutan Teori 3 Latihan 7 (Mencari Bilangan Genap)


Public Class latihan7
        'rafif karunia rahman 2017230174
    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
        Dim x, i As Integer
        x = Val(TextBox1.Text)
        i = 1
        x = x + 1
        ListBox1.Items.Clear()
        While i < 11
            If x Mod 2 = 0 Then
                ListBox1.Items.Add(x)
                i = i + 1
            End If
            x = x + 1
        End While
    End Sub

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

    End Sub
End Class

Visual Lanjutan Teori 3 Latihan 6 (Perulangan While)


Public Class latihan6
        'RAFIF KARUNIA RAHMAN 2017230174
    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
        Dim x As Integer
        x = 1
        While x <= 10
            ListBox1.Items.Add(x)
            x = x + 1
        End While
    End Sub

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

    End Sub
End Class

Visual Lanjutan Teori 3 Latihan 5 (Nested For)


Public Class latihan5
    'rafif karunia rahman 2017230174'
    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
        Dim x, y As Integer
        For x = 1 To 3
            For y = 1 To 2
                ListBox1.Items.Add(x & y)
            Next y
        Next x
    End Sub

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

    End Sub
End Class

Visual Lanjutan Teori 3 Latihan 4 (For Next)


Public Class latihan4
    'rafif karunia rahman 2017230174
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For i = 1 To 7
            ListBox1.Items.Add(WeekdayName(i))
        Next
    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 latihan4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

Visual Lanjutan Teori 3 Latihan 3 (For Next)


Public Class latihan3
    'RAFIF KARUNIA RAHMAN
    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
        Dim x, y, i, hasil As Integer
        x = Val(TextBox1.Text)
        y = Val(TextBox2.Text)
        hasil = 1
        For i = 1 To y
            hasil = hasil * x
            On Error Resume Next
            TextBox3.Text = Str(hasil)
        Next
    End Sub

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

    End Sub
End Class

Visual Lanjutan Teori 3 Latihan 2 (For Next)



Public Class latihan2
    'RAFIF KARUNIA RAHMAN
    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
        Dim x As Integer
        For x = 10 To 1 Step -1
            ListBox1.Items.Add(x)
        Next x
    End Sub

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

    End Sub
End Class

Visual Lanjutan Teori 3 Latihan 1 (For Next)


Public Class latihan1
    'RAFIF KARUNIA RAHMAN
    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
        Dim x As Integer
        For x = 1 To 10
            ListBox1.Items.Add(x)
        Next x
    End Sub
End Class

Visual Lanjutan PRAKTEK 3 Kasus 3 (For Next)


Public Class kasus3
    'RAFIF KARUNIA RAHMAN 2017230174
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim angka As Integer
        For angka = TextBox1.Text To TextBox2.Text
            If angka Mod 2 = 0 Then
                ListBox2.Items.Add(angka)
            Else
                ListBox1.Items.Add(angka)
            End If
        Next angka
    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 kasus3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

Visual Lanjutan PRAKTEK 3 Kasus 2 (For Next)


Public Class kasus2
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pesan As String
        pesan = MsgBox("Yakin Ingin Keluar??", vbYesNo, "Konfirmasi")
        If pesan = vbYes Then
            End
        End If
    End Sub
    Private Sub kasus2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.Text = "-Tanggal-"
        ComboBox2.Text = "-Bulan-"
        ComboBox3.Text = "-Tahun-"
        For i = 1 To 31
            ComboBox1.Items.Add(Str(i))
        Next i
        For i = 1 To 12
            ComboBox2.Items.Add(MonthName(i))
        Next i
        For i = 1990 To Year(Now)
            ComboBox3.Items.Add(Str(i))
        Next i
    End Sub
End Class

Visual Lanjutan PRAKTEK 3 Kasus 2 (For Next)


Public Class kasus1
    'RAFIF KARUNIA RAHMAN
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For i = 1 To 12
            ListBox1.Items.Add(MonthName(i))
        Next
    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
End Class

Visual Lanjutan Rangkuman Praktek 3

1. Do While – Loop
Pengulangan Do While ... Loop merupakan loop yang sangat mirip dengan While ... End While. Yang membedakan Do While ... Loop dengan While ... End While adalah perintah Exit Do. Perintah tersebut adalah perintah untuk memaksa program menghentikan pengulangan sebelum pengulangan berakhir pada bentuk pengulangan Do While ... Loop.

2. Do – Loop While
Bentuk pengulangan Do ... Loop While berhenti jika kondisi telah bernilai salah (false). Selama kondisi masih bernilai benar (true), pengulangan akan dilakukan terus. Bentuk pengulangan Do ... Loop While merupakan bentuk pengulangan yang kondisinya terletak di akhir pengulangan.

3. Do Until – Loop
Bentuk pengulangan Do Until ... Loop hampir sama dengan pengulangan While ... End While dan Do While ... Loop. Perbedaannya adalah kalau pada pengulangan bentuk While ... End While dan Do While ... Loop pengulangan dihentikan pada waktu kondisi bernilai salah (false), sedangkan pada bentuk Do Until ... Loop pengulangan dihentikan pada waktu kondisi bernilai benar (true).

4. Do – Loop Until
Bentuk pengulangan Do ... Loop Until sama dengan bentuk Do ... Loop While. Pengulangan berhenti jika kondisi telah bernilai benar (true). Jadi selama kondisi masih bernilai salah (false), pengulangan akan dilakukan terus. Bentuk pengulangan Do ... Loop While merupakan pengulangan yang memeriksa kondisinya terletak di akhir pengulangan sehingga pengulangan minimal dilakukan 1 kali (mirip dengan Do ... Loop While).

Visual Lanjutan Rangkuman Teori 3

1. For-Next
Digunakan untuk mengulang perintah dalam jumlah yang ditentukan. pada for-next kita tidak perlu menuliskan kondisi yang akan yang akan di uji, tetapi cukup hanya memberikan nilai step awal dan akhir nilai.
Sintaks:
For variabel = nilai_awal To nilai_akhir
     ekspresi
Next
Keterangan :
variabel : nama integer yang digunakan untuk melakukan proses perulangan
nilai_awal : nilai awal suatu variabel untuk menentukan awal perulangan
nilai_akhir : nilai suatu variabel untu menentukan akhir dari perulangan
ekpresi : blok perintah yang akan dilakukan jika kondisi perulangan memenuhi syarat.
Contoh:
-Membuat Teks “Visual Basic” sebanyak 10 pada Objek ListBox
Dim i As Integer
listbox1.Items.Clear()
For i = 1 to 10
    listbox1.Items.Add(“Visual Basic”)
Next

-Membuat Deret angka 1 sampai 10
Dim i As Integer
listbox1.Items.Clear()
For i = 1 to 10
    listbox1.Items.Add(i)
Next


2. Do-Loop
Perulangan Do…Loop digunakan untuk perulangan yang jumlah perulangannya tidak diketahui. Perulangan ini akan dijalankan sesuai kondisi yang telah ditetapkan.
Pemeriksaan Kondisi pada Do…Loop dapat dilakukan diawal dan diakhir.
Kondisi akan dijalankan pada dua keadaan yaitu Until dan While.

2.1. Do…Loop dengan Pemeriksaan diawal
-Do Until … Loop
Perulangan akan dilakukan ketika kondisi bernilai salah dan berhenti sampai ketika kondisi bernilai benar.
Sintaks:
Do Until (Kondisi)
     ekspresi
Loop

Keterangan:
kondisi : suatu kondisi berupa syarat tertentu, jika kondisi bernilai benar maka perulangan masih terus dilakukan, sebaliknya jika kondisi bernilan salah maka perulangan akan berhenti.
ekpresi : blok perintah yang akan dilakukan jika kondisi perulangan memenuhi syarat.
Contoh:
Membuat Deret angka 1 sampai 10
Dim i As Integer
i = 1
listbox1.Items.Clear()
Do Until i > 10
listbox1.Items.Add(i)
i=i+1
Loop

-Do While … Loop
Loop dengan do While cocok digunakan pada perulangan yang terjadi selama kondisi tertentu memenuhi syarat (selama kondisi benar, statement akan dijalankan terus).
Sintaks:
Do While (Kondisi)
     ekspresi
Loop

Keterangan:
kondisi : suatu kondisi berupa syarat tertentu, jika kondisi bernilai benar maka perulangan masih terus dilakukan, sebaliknya jika kondisi bernilan salah maka perulangan akan berhenti.
ekpresi : blok perintah yang akan dilakukan jika kondisi perulangan memenuhi syarat.
Contoh:
Membuat Deret angka 1 sampai 10
Dim i As Integer
i = 1
listbox1.Items.Clear()
Do while i > 10
listbox1.Items.Add(i)
i=i+1
Loop

2.2. Do…Loop dengan Pemeriksaan diakhir
-Do … Loop Until
Perulangan akan dilakukan ketika kondisi bernilai salah dan berhenti sampai ketika kondisi bernilai benar.
Sintaks:
Do
     ekspresi
Loop Until (Kondisi)

Keterangan:
kondisi : suatu kondisi berupa syarat tertentu, jika kondisi bernilai benar maka perulangan masih terus dilakukan, sebaliknya jika kondisi bernilan salah maka perulangan akan berhenti.
ekpresi : blok perintah yang akan dilakukan jika kondisi perulangan memenuhi syarat.
Contoh:
Membuat Deret angka 1 sampai 10
Dim i As Integer
i = 1
listbox1.Items.Clear()
Do
listbox1.Items.Add(i)
i=i+1
Loop Until i > 10

-Do … Loop While
Loop dengan do While cocok digunakan pada perulangan yang terjadi selama kondisi tertentu memenuhi syarat (selama kondisi benar, statement akan dijalankan terus).
Sintaks:
Do
     ekspresi
Loop While (Kondisi)

Keterangan:
kondisi : suatu kondisi berupa syarat tertentu, jika kondisi bernilai benar maka perulangan masih terus dilakukan, sebaliknya jika kondisi bernilan salah maka perulangan akan berhenti.
ekpresi : blok perintah yang akan dilakukan jika kondisi perulangan memenuhi syarat.


3. While-End While
Perulangan While…End While tidak jauh berbeda dengan perulangan do … loop digunakan untuk perulangan yang jumlah perulangannya tidak diketahui. Perulangan ini akan dijalankan sesuai kondisi yang telah ditetapkan.
Sintaks:
While (Kondisi)
     ekspresi
End While

Keterangan:
kondisi : suatu kondisi berupa syarat tertentu, jika kondisi bernilai benar maka perulangan masih terus dilakukan, sebaliknya jika kondisi bernilan salah maka perulangan akan berhenti.
ekpresi : blok perintah yang akan dilakukan jika kondisi perulangan memenuhi syarat.
Contoh:
Membuat Deret angka 1 sampai 10
Dim i As Integer
i = 1
ListBox1.Items.Clear()
While i <= 10
    ListBox1.Items.Add(i)
    i = i + 1
End While

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

Visual Lanjutan PRAKTEK 2 Kasus 10(SWITCH CASE)



Public Class kasus10
'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
        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

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

    End Sub
End Class

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

Visual Lanjutan PRAKTEK 2 Kasus 8(SELECT CASE)


Public Class kasus8
    'RAFIF KARUNIA RAHMAN 2017230174
    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
    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

Visual Lanjutan PRAKTEK 2 Kasus 7(PERCABANGAN IF)


Public Class kasus7
'RAFIF KARUNIA RAHMAN 2017230174
    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

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

    End Sub
End Class

Visual Lanjutan PRAKTEK 2 Kasus 6(PERCABANGAN IF)


Public Class kasus6
    'RAFIF KARUNIA RAHMAN 2017230174
    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

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

    End Sub
End Class

Visual Lanjutan PRAKTEK 2 Kasus 5(NESTED IF)


Public Class kasus5
'RAFIF KARUNIA RAHMAN 2017230174
    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
        If ComboBox1.Text = "IMP" Then
            If ComboBox2.Text = "XL" Then
                harga = 250000
            ElseIf ComboBox2.Text = "L" Then
                harga = 240000
            ElseIf ComboBox2.Text = "M" Then
                harga = 230000
            End If
        ElseIf ComboBox1.Text = "Prada" Then
            If ComboBox2.Text = "XL" Then
                harga = 170000
            ElseIf ComboBox2.Text = "L" Then
                harga = 160000
            ElseIf ComboBox2.Text = "M" Then
                harga = 150000
            End If
        ElseIf ComboBox1.Text = "Gucci" Then
            If ComboBox2.Text = "XL" Then
                harga = 280000
            ElseIf ComboBox2.Text = "L" Then
                harga = 270000
            ElseIf ComboBox2.Text = "M" Then
                harga = 260000
            End If
        ElseIf ComboBox1.Text = "Loius" Then
            If ComboBox2.Text = "XL" Then
                harga = 360000
            ElseIf ComboBox2.Text = "L" Then
                harga = 350000
            ElseIf ComboBox2.Text = "M" Then
                harga = 340000
            End If
        ElseIf ComboBox1.Text = "Denim" Then
            If ComboBox2.Text = "XL" Then
                harga = 130000
            ElseIf ComboBox2.Text = "L" Then
                harga = 120000
            ElseIf ComboBox2.Text = "M" Then
                harga = 110000
            End If
        End If
        TextBox2.Text = harga
        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 kasus5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class