Option Explicit
Dim intCount As Integer
Dim sngOne As Single
Dim sngTwo As Single
Private Sub cmd0_Click()
txtAnswer.Text = txtAnswer.Text & "0"
End Sub
Private Sub cmd1_Click()
txtAnswer.Text = txtAnswer.Text & "1"
End Sub
Private Sub cmd2_Click()
txtAnswer.Text = txtAnswer.Text & "2"
End Sub
Private Sub cmd3_Click()
txtAnswer.Text = txtAnswer.Text & "3"
End Sub
Private Sub cmd4_Click()
txtAnswer.Text = txtAnswer.Text & "4"
End Sub
Private Sub cmd5_Click()
txtAnswer.Text = txtAnswer.Text & "5"
End Sub
Private Sub cmd6_Click()
txtAnswer.Text = txtAnswer.Text & "6"
End Sub
Private Sub cmd7_Click()
txtAnswer.Text = txtAnswer.Text & "7"
End Sub
Private Sub cmd8_Click()
txtAnswer.Text = txtAnswer.Text & "8"
End Sub
Private Sub cmd9_Click()
txtAnswer.Text = txtAnswer.Text & "9"
End Sub
Private Sub cmdClear_Click()
txtAnswer.Text = ""
End Sub
Private Sub cmdDecimal_Click()
txtAnswer.Text = txtAnswer.Text & "."
End Sub
Private Sub cmdDLeft_Click()
sngOne = txtAnswer.Text
intCount = 0
txtAnswer.Text = ""
intCount = intCount + 5
End Sub
Private Sub cmdDRight_Click()
sngOne = txtAnswer.Text
intCount = 0
txtAnswer.Text = ""
intCount = intCount + 4
End Sub
Private Sub cmdEqual_Click()
sngTwo = txtAnswer.Text
If intCount = 1 Then
txtAnswer.Text = sngOne + sngTwo
End If
If intCount = 2 Then
txtAnswer.Text = sngOne - sngTwo
End If
If intCount = 3 Then
txtAnswer.Text = sngOne * sngTwo
End If
If intCount = 4 Then
txtAnswer.Text = sngOne \ sngTwo
End If
If intCount = 5 Then
txtAnswer.Text = sngOne / sngTwo
End If
If intCount = 6 Then
txtAnswer.Text = sngOne ^ sngTwo
End If
If intCount = 7 Then
txtAnswer.Text = sngOne ^ (1 / sngTwo)
End If
If intCount = 8 Then
txtAnswer.Text = sngOne Mod sngTwo
End If
End Sub
Private Sub cmdFix_Click()
txtAnswer.Text = Fix(Val(txtAnswer.Text))
End Sub
Private Sub cmdMinus_Click()
sngOne = txtAnswer.Text
intCount = 0
txtAnswer.Text = ""
intCount = intCount + 2
End Sub
Private Sub cmdMOD_Click()
sngOne = txtAnswer.Text
intCount = 0
txtAnswer.Text = ""
intCount = intCount + 8
End Sub
Private Sub cmdOnOff_Click()
If cmdOnOff.Caption = "Off" Then
End
End If
If cmdOnOff.Caption = "On" Then
frmCalculator.BackColor = &H0&
txtName.BackColor = &H0&
cmdOnOff.Caption = "Off"
cmd0.Enabled = True
cmd1.Enabled = True
cmd2.Enabled = True
cmd3.Enabled = True
cmd4.Enabled = True
cmd5.Enabled = True
cmd6.Enabled = True
cmd7.Enabled = True
cmd8.Enabled = True
cmd9.Enabled = True
cmdDecimal.Enabled = True
cmdClear.Enabled = True
cmdEqual.Enabled = True
cmdPlus.Enabled = True
cmdMinus.Enabled = True
cmdTimes.Enabled = True
cmdDRight.Enabled = True
cmdDLeft.Enabled = True
cmdMOD.Enabled = True
cmdFix.Enabled = True
cmdRoot.Enabled = True
cmdPower.Enabled = True
End If
End Sub
Private Sub cmdPlus_Click()
sngOne = txtAnswer.Text
intCount = 0
txtAnswer.Text = ""
intCount = intCount + 1
End Sub
Private Sub cmdPower_Click()
sngOne = txtAnswer.Text
intCount = 0
txtAnswer.Text = ""
intCount = intCount + 6
End Sub
Private Sub cmdRoot_Click()
sngOne = txtAnswer.Text
intCount = 0
txtAnswer.Text = ""
intCount = intCount + 7
End Sub
Private Sub cmdTimes_Click()
sngOne = txtAnswer.Text
intCount = 0
txtAnswer.Text = ""
intCount = intCount + 3
End Sub
That's my code thus far.
My problem now is basically just that I can enter numbers and calculate them, but I can't do longer equations. For example:
No problem doing that at all.
In our assignment we should be able to do equations like this:
Instead, it would do the last two numbers along with their sign.
So it would end up being 3 ^ 2 = 9.
I don't know how to make it so that it will do the entire equation rather than the last parts of it.
We can
not use things like As Double, As Boolean, etc...
So if it can be done using things like As Integer, As Single, or As String please use that method.