VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This is a standard calculator.Please take coresponding controls on the form and just add this code

by ojas (14 Submissions)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 1st October 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This is a standard calculator.Please take coresponding controls on the form and just add this code to them

API Declarations




Dim X As Double
Dim operand1 As Double, operand2 As Double
Dim cleardisplay As Boolean
Dim operator As String


Rate This is a standard calculator.Please take coresponding controls on the form and just add this code



txt1.Text = txt1.Text + "3"
End Sub

Private Sub cmd11_Click()
txt1.SetFocus
txt1.Text = txt1.Text + "0"
End Sub

Private Sub cmd2_Click()
txt1.Text = txt1.Text + "7"

End Sub

Private Sub cmd3_Click()
txt1.Text = txt1.Text + "8"

End Sub

Private Sub cmd4_Click()

txt1.Text = txt1.Text + "9"

End Sub

Private Sub cmd5_Click()
txt1.Text = txt1.Text + "4"

End Sub

Private Sub cmd6_Click()
txt1.Text = txt1.Text + "5"
End Sub

Private Sub cmd7_Click()
txt1.Text = txt1.Text + "6"
End Sub

Private Sub cmd8_Click()
txt1.Text = txt1.Text + "1"

End Sub

Private Sub cmd9_Click()
txt1.Text = txt1.Text + "2"
End Sub

Private Sub Command1_Click()
txt1.Text = " "
cmd2.Enabled = False
cmd3.Enabled = False
cmd4.Enabled = False
cmd5.Enabled = False
cmd6.Enabled = False
cmd7.Enabled = False
cmd8.Enabled = False
cmd9.Enabled = False
cmd10.Enabled = False

End Sub

Private Sub cmd1_Click()

cmd2.Enabled = True
cmd3.Enabled = True
cmd4.Enabled = True
cmd5.Enabled = True
cmd6.Enabled = True
cmd7.Enabled = True
cmd8.Enabled = True
cmd9.Enabled = True

cmd10.Enabled = True

End Sub

Private Sub Command10_Click()
txt1.SetFocus
operand1 = Val(txt1.Text)
operator = "%"

End Sub

Private Sub Command11_Click()
txt1.Text = txt1.Text + "."
End Sub

Private Sub Command2_Click()
Dim s As String
s = MsgBox("Are you sure?", vbYesNo, "Quit?")
If s = vbYes Then
MsgBox "Programmed by ojas"
End
End If


End Sub

Private Sub Command3_Click()
txt1.SetFocus
txt1.Text = " "
End Sub

Private Sub Command4_Click()
txt1.SetFocus
Dim s As String

s = MsgBox("Are you sure?", vbYesNo, "Clear")
If s = vbYes Then
txt1.Text = " "
End If

End Sub

Private Sub Command3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command3.ToolTipText = "Clear"
End Sub

Private Sub Command5_Click()
txt1.SetFocus
operand1 = Val(txt1.Text)
operator = "+"
txt1.Text = " "
End Sub

Private Sub Command6_Click()
txt1.SetFocus
operand1 = Val(txt1.Text)
operator = "/"
txt1.Text = " "
End Sub

Private Sub Command7_Click()
txt1.SetFocus
operand1 = Val(txt1.Text)
operator = "*"
txt1.Text = " "
End Sub

Private Sub Command8_Click()
txt1.SetFocus
operand1 = Val(txt1.Text)
operator = "-"
txt1.Text = " "
End Sub

Private Sub Command9_Click()

Dim result As Double
operand2 = Val(txt1.Text)
If operator = "-" Then result = operand1 - operand2
If operator = "*" Then result = operand1 * operand2
If operator = "+" Then result = operand1 + operand2
If operator = "/" Then result = operand1 / operand2
If operator = "%" Then result = (operand1 / operand2) * 100
txt1.Text = result

End Sub

Private Sub Form_Load()
txt1.Locked = True
cmd2.Enabled = False
cmd3.Enabled = False
cmd4.Enabled = False
cmd5.Enabled = False
cmd6.Enabled = False
cmd7.Enabled = False
cmd8.Enabled = False
cmd9.Enabled = False
cmd10.Enabled = False
End Sub


Download this snippet    Add to My Saved Code

This is a standard calculator.Please take coresponding controls on the form and just add this code Comments

No comments have been posted about This is a standard calculator.Please take coresponding controls on the form and just add this code . Why not be the first to post a comment about This is a standard calculator.Please take coresponding controls on the form and just add this code .

Post your comment

Subject:
Message:
0/1000 characters