PROGRAM OPERASI ARITMATIKA (VISUAL BASIC)


Dim a1 As Single, a2 As Single
Dim hasil As Single

Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Label3.Caption = ""
Option1 = False
Option2 = False
Option3 = False
Option4 = False
Option5 = False
Option6 = False
Option7 = False
Option8 = False
End Sub

Private Sub Option1_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "Anda belum mengisi inputnya", vbInformation, "KESALAHAN!"
Option1 = False
Else
a1 = Text1.Text
a2 = Text2.Text
hasil = a1 ^ a2
Label3.Caption = hasil
End If
End Sub

Private Sub Option2_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "Anda belum mengisi inputnya", vbInformation, "KESALAHAN!"
Option2 = False
Else
a1 = Text1.Text
a2 = Text2.Text
hasil = a1 - a2
Label3.Caption = hasil
End If
End Sub

Private Sub Option3_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "Anda belum mengisi inputnya", vbInformation, "KESALAHAN!"
Option3 = False
Else
a1 = Text1.Text
a2 = Text2.Text
hasil = a1 * a2
Label3.Caption = hasil
End If
End Sub

Private Sub Option4_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "Anda belum mengisi inputnya", vbInformation, "KESALAHAN!"
Option4 = False
Else
a1 = Text1.Text
a2 = Text2.Text
hasil = a1 / a2
Label3.Caption = hasil
End If
End Sub

Private Sub Option5_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "Anda belum mengisi inputnya", vbInformation, "KESALAHAN!"
Option6 = False
Else
a1 = Text1.Text
a2 = Text2.Text
hasil = a1 \ a2
Label3.Caption = hasil
End If
End Sub

Private Sub Option6_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "Anda belum mengisi inputnya", vbInformation, "KESALAHAN!"
Option6 = False
Else
a1 = Text1.Text
a2 = Text2.Text
hasil = a1 Mod a2
Label3.Caption = hasil
End If
End Sub

Private Sub Option7_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "Anda belum mengisi inputnya", vbInformation, "KESALAHAN!"
Option7 = False
Else
a1 = Text1.Text
a2 = Text2.Text
hasil = a1 + a2
Label3.Caption = hasil
End If
End Sub

Private Sub Option8_Click()
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "Anda belum mengisi inputnya", vbInformation, "KESALAHAN!"
Option8 = False
Else
a1 = Text1.Text
a2 = Text2.Text
hasil = a1 & a2
Label3.Caption = hasil
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then

End If
If (KeyAscii = 48 Or KeyAscii = 49 Or KeyAscii = 50 Or KeyAscii = 51 Or KeyAscii = 52 Or KeyAscii = 53 Or KeyAscii = 54 Or KeyAscii = 55 Or KeyAscii = 56 Or KeyAscii = 57) Then
ElseIf (KeyAscii = vbKeyReturn Or KeyAscii = vbKeyDelete) Then
KeyAscii = 0
ElseIf KeyAscii = vbKeyBack Then
Else
KeyAscii = 0
MsgBox "Maaf, anda hanya bisa input angka saja!", vbInformation, "KESALAHAN"
Exit Sub
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then

End If
If (KeyAscii = 48 Or KeyAscii = 49 Or KeyAscii = 50 Or KeyAscii = 51 Or KeyAscii = 52 Or KeyAscii = 53 Or KeyAscii = 54 Or KeyAscii = 55 Or KeyAscii = 56 Or KeyAscii = 57) Then
ElseIf (KeyAscii = vbKeyReturn Or KeyAscii = vbKeyDelete) Then
KeyAscii = 0
ElseIf KeyAscii = vbKeyBack Then
Else
KeyAscii = 0
MsgBox "Maaf, anda hanya bisa input angka saja!", vbInformation, "KESALAHAN"
Exit Sub
End If
End Sub


program lengkap download disini :
aritmatika2.rar

0 komentar:

 

Usage Rights

DesignBlog BloggerTheme comes under a Creative Commons License.This template is free of charge to create a personal blog.You can make changes to the templates to suit your needs.But You must keep the footer links Intact.