Rabu, 25 Maret 2020

Visual Lanjutan PRAKTEK 2 Kasus 1 (If-Then-Else)

Public Class kasus1
'RAFIF KARUNIA RAHMAN
'2017230174
    Dim kd, nama, kategori As String
    Dim harga, jumlah, subtotal, diskon, total, 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 = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        ComboBox1.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
            harga = TextBox3.Text
            jumlah = TextBox4.Text
            TextBox5.Text = harga * jumlah
        End If
        If (e.KeyChar = Chr(13)) Then
            TextBox5.Focus()
        End If
    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
            total = TextBox7.Text
            TextBox9.Text = bayar - total
        End If
        If (e.KeyChar = Chr(13)) Then
            TextBox9.Focus()
        End If
    End Sub
    Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
        subtotal = TextBox5.Text
        If subtotal >= 100000 Then
            TextBox6.Text = subtotal * (5 / 100)
        Else
            TextBox6.Text = 0
        End If
        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
            subtotal = TextBox5.Text
            diskon = TextBox6.Text
            TextBox7.Text = subtotal - diskon
        End If
        If (e.KeyChar = Chr(13)) Then
            TextBox7.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
            TextBox4.Focus()
        End If
    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
            TextBox8.Focus()
        End If
    End Sub

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

    End Sub
End Class

Tidak ada komentar:

Posting Komentar