AULIA PUSPA NABILA Visual Studio

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Nama: AULIA PUSPA NABILA

Nim: 1001200017

Prodi: SISTEM INFORMASI REGULER

Public Class Form1


Public harga, jumlah, subtotal, bayar, kembali As Integer
Public diskon, tagihan As Double

Private Sub txtjumlah_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


txtjumlah.KeyPress

' Validasi TextBox Jumlah Beli Hanya Bisa Diisi Oleh Angka
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then
e.Handled = True

harga = Val(txtharga.Text)
jumlah = Val(txtjumlah.Text)
subtotal = harga * jumlah
txtsub.Text = subtotal

diskon = Val(txtdiskon.Text)
tagihan = Val(txttagihan.Text)
If txtsub.Text > 100000 Then
diskon = 0.05 * subtotal
Else
diskon = 0
End If
txtdiskon.Text = diskon
tagihan = subtotal - diskon
txttagihan.Text = tagihan
txtbayar.Focus()
End Sub

Private Sub txtjumlah_TextChanged(sender As Object, e As EventArgs) Handles


txtjumlah.TextChanged

End Sub

Private Sub txtbayar_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


txtbayar.KeyPress
' Validasi TextBox Uang Bayar Hanya Bisa Diisi Oleh Angka
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then
e.Handled = True

tagihan = Val(txttagihan.Text)
bayar = Val(txtbayar.Text)
kembali = bayar - tagihan
txtkembali.Text = "Rp. " & kembali
End Sub
Private Sub txtbayar_TextChanged(sender As Object, e As EventArgs) Handles
txtbayar.TextChanged
End Sub
Private Sub btclear_Click(sender As Object, e As EventArgs)
txtkode.Text = ""
txtnama.Text = ""
cbkategori.Text = ""
txtharga.Text = ""
txtjumlah.Text = ""
txtsub.Text = ""
txtdiskon.Text = ""
txttagihan.Text = ""
txtbayar.Text = ""
txtkembali.Text = ""
txtkode.Focus()

End Sub

Private Sub btkeluar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btkeluar.Click
Dim pesan As String
pesan = MsgBox("Yakin mau keluar?", vbYesNo, "Konfirmasi")
If pesan = vbYes Then
Close()
End If
End Sub
Private Sub txtnama_KeyPress(sender As Object, e As KeyPressEventArgs) Handles
txtnama.KeyPress
' Validasi TextBox Nama Buku Hanya Bisa Diisi Oleh huruf Saja
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
e.Handled = CBool(KeyAscii)
' TextBox Nama Buku di enter, maka aktif di Combobox
If (e.KeyChar = Chr(13)) Then
cbkategori.Focus()
End If
End Sub
Private Sub txtnama_TextChanged(sender As Object, e As EventArgs) Handles
txtnama.TextChanged

End Sub
Private Sub txtharga_KeyPress(sender As Object, e As KeyPressEventArgs) Handles
txtharga.KeyPress
' Validasi TextBox Hanya Bisa Diisi Oleh Angka
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then
e.Handled = True

If (e.KeyChar = Chr(13)) Then


txtjumlah.Focus()
End If
End Sub
Private Sub txtharga_TextChanged(sender As Object, e As EventArgs) Handles
txtharga.TextChanged
End Sub
Private Sub txtkode_KeyPress(sender As Object, e As KeyPressEventArgs) Handles
txtkode.KeyPress
' Textbox Kode di enter, maka akan aktif di Texbox Nama Barang
If (e.KeyChar = Chr(13)) Then
txtnama.Focus()
End If
End Sub
Private Sub txtkode_TextChanged(sender As Object, e As EventArgs) Handles
txtkode.TextChanged

End Sub
Private Sub cbkategori_KeyPress(sender As Object, e As KeyPressEventArgs) Handles
cbkategori.KeyPress
' Textbox Nama Barang di enter, maka akan aktif di Combobox
If (e.KeyChar = Chr(13)) Then
txtharga.Focus()
End If
End Sub
Private Sub cbkategori_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
cbkategori.SelectedIndexChanged

End Sub
End
Class

 Kode Buku, Nama Buku, Kategori Buku, harga buku, dan jumlah beli diinput.
 Gunakan event keypress untuk input dengan keyboard.
 Gunakan validasi untuk huruf dan angka.
 Ketika di enter di textbox jumlah beli, sub total, diskon dan total tagihan akan muncul.
 Uang bayar diinput, klik enter maka uang kembali akan muncul.
 Button Clear untuk membersihkan
 Button keluar untuk keluar aplikasi.

You might also like