Kasus 4 : Menggunakan Operator
Public Class kas4
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 = Microsoft.VisualBasic.ChrW(Keys.Return) Then
SendKeys.Send("{TAB}")
e.Handled = True
Dim phi, nilai, luas, kel As Double
phi = 3.14
nilai = TextBox1.Text
luas = phi * nilai * nilai
kel = 2 * phi * nilai
TextBox2.Text = luas
TextBox3.Text = kel
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim pesan As String
pesan = MsgBox("Yakin Ingin Keluar ??", vbYesNo, "Konfirmasi")
If pesan = vbYes Then
Close()
End
End If
End Sub
End Class
Kasus 5 : Menggunakan Operator
Berikut Source Codenya :
Public Class kas5
Dim kd, nama, satuan As String
Dim harga, jumlah, total, bayar, kembali As Integer
'nadiahtami 201723007'
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 = Microsoft.VisualBasic.ChrW(Keys.Return) Then
SendKeys.Send("{TAB}")
harga = TextBox3.Text
jumlah = TextBox4.Text
TextBox5.Text = harga * jumlah
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 = Microsoft.VisualBasic.ChrW(Keys.Return) Then
SendKeys.Send("{TAB}")
total = TextBox5.Text
bayar = TextBox6.Text
TextBox7.Text = bayar - total
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 = ""
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
Close()
End
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
e.Handled = CBool(keyascii)
End Sub
End Class
Kasus 6 : Menggunakan Operator
Berikut Source Codenya :
Public Class kas6
Dim kd, nama, kategori As String
Dim harga, jumlah, total, bayar, kembali As Integer
'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 = Microsoft.VisualBasic.ChrW(Keys.Return) Then
SendKeys.Send("{TAB}")
harga = TextBox3.Text
jumlah = TextBox4.Text
TextBox5.Text = harga * jumlah
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 = Microsoft.VisualBasic.ChrW(Keys.Return) Then
SendKeys.Send("{TAB}")
total = TextBox5.Text
bayar = TextBox6.Text
TextBox7.Text = bayar - total
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 = ""
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
Close()
End
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
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
End Sub
End Class
Komentar
Posting Komentar