TUTORIAL - disini admin akan memberikan cara membuat kalkulator pada Visual Basic.
Kemudian Masukan Koding dibawah ini :
Private Sub Command8_Click()
MsgBox "1. Isi Angka 1 lalu tekan [ENTER]" & vbNewLine & "2. Isi
Angka 2 lalu tekan [ENTER]" & vbNewLine & "3. Lalu Pilih
Kalkulasi yang diinginkan", vbInformation, "Petunjuk"
End Sub
Private Sub Form_Load()
Text3.Enabled = False
End Sub
Private Sub Command1_Click()
'Ini untuk coding tambah
If Text1 = "" Or Text2 = "" Then
MsgBox "Data Belum Lengkap"
Text1.SetFocus
Else
Text3 = Val(Text1) + Val(Text2)
End If
End Sub
Private Sub Command2_Click()
If Text1 = "" Or Text2 = "" Then
MsgBox "Data Belum Lengkap"
Text1.SetFocus
Else
Text3 = Text1 - Text2
End If
End Sub
Private Sub Command3_Click()
If Text1 = "" Or Text2 = "" Then
MsgBox "Data Belum Lengkap"
Text1.SetFocus
Else
Text3 = Text1 / Text2
End If
End Sub
Private Sub Command4_Click()
If Text1 = "" Or Text2 = "" Then
MsgBox "Data Belum Lengkap"
Text1.SetFocus
Else
Text3 = Text1 * Text2
End If
End Sub
Private Sub Command5_Click()
If Text1 = "" Or Text2 = "" Then
MsgBox "Data Belum Lengkap"
Text1.SetFocus
Else
Text3 = Val(Text1) ^ Val(Text2)
End If
End Sub
Private Sub Command6_Click()
End
End Sub
Private Sub Command7_Click()
KosongkanText
Text1.SetFocus
End Sub
Private Sub Text1_KeyPress(Keyascii As Integer)
If Keyascii = 13 Then Text2.SetFocus
If Not (Keyascii >= Asc("0") And Keyascii <= Asc("9") Or Keyascii = vbKeyBack Or Keyascii = vbKeyReturn) Then Keyascii = 0
End Sub
Private Sub Text2_KeyPress(Keyascii As Integer)
If Keyascii = 13 Then Command1.SetFocus
If Not (Keyascii >= Asc("0") And Keyascii <= Asc("9") Or Keyascii = vbKeyBack Or Keyascii = vbKeyReturn) Then Keyascii = 0
End Sub
Private Sub KosongkanText()
Text1 = ""
Text2 = ""
Text3 = ""
End Sub
Semoga berhasil sobat Tutorial,Salam Refzqi
sumber:http://pintarvb.blogspot.com
ADS HERE !!!