Tutorial Visual Basic-Make simple Calculator

p
Berikut source code nya semoga bermanfaat bagi kalian yang membaca

CODE

Private Sub cmdAdd_Click()
lblAnswer.Caption = Val(txtFn.Text) + Val(txtSn.Text)
End Sub

Private Sub cmdClear_Click()
txtFn.Text = “”
txtSn.Text = “”
lblAnswer = “0.00”
End Sub

Private Sub cmdCon_Click()
lblAnswer.Caption = txtFn.Text + txtSn.Text
End Sub

Private Sub cmdDiv_Click()
lblAnswer.Caption = Val(txtFn.Text) / Val(txtSn.Text)
End Sub

Private Sub cmdExit_Click()
If MsgBox(“Are you sure you want to close My Calculator?”, vbQuestion + vbYesNo, “Close Applet”) = vbYes Then
End
Else
txtFn.SetFocus
End If
End Sub

Private Sub cmdExp_Click()
lblAnswer.Caption = Val(txtFn.Text) ^ Val(txtSn.Text)
End Sub

Private Sub cmdInt_Click()
lblAnswer.Caption = Val(txtFn.Text) \ Val(txtSn.Text)
End Sub

Private Sub cmdMod_Click()
lblAnswer.Caption = Val(txtFn.Text) Mod Val(txtSn.Text)
End Sub

Private Sub cmdMul_Click()
lblAnswer.Caption = Val(txtFn.Text) * Val(txtSn.Text)
End Sub

Private Sub cmdSub_Click()
lblAnswer.Caption = Val(txtFn.Text) – Val(txtSn.Text)
End Sub

Private Sub textempty()
If txtFn.Text = “” And txtSn.Text = “” Then
MsgBox “Empty Fields!”, , “Text Empty”
txtFn.SetFocus
lblAnswer.Caption = “0.00”
End If
End Sub

Private Sub textnotnum()
If IsNumeric(txtFn.Text) = False Then
MsgBox “Enter Number Only!”, vbInformation, “Validation”
txtFn.SetFocus
End If
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s