I got every other operation button to work besides sqrt, and percentage. I've done the same thing for addition, subtraction, etc. and it doesn't seem to work.
here's my globals
here's my globals
Code:
Public Class Form1
Private first As Double
Private second As Double
Private oper As String
Private negpos As Boolean
Code:
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
first = txtoutput.Text
txtoutput.Clear()
oper = "+"
End Sub
Private Sub btnEqual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEqual.Click
second = txtoutput.Text
If (oper = "+") Then
txtoutput.Text = first + second
Else
If (oper = "-") Then
txtoutput.Text = first - second
Else
If (oper = "*") Then
txtoutput.Text = first * second
Else
If (oper = "/") Then
txtoutput.Text = first / second
Else
If (oper = "s") Then
txtoutput.Text = System.Math.Sqrt(first)
Else
If (oper = "%") Then
txtoutput.Text = (first * second) / 100
End If
End If
End If
End If
End If
End If
End Sub
Private Sub btnSubstract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubstract.Click
first = txtoutput.Text
txtoutput.Clear()
oper = "-"
End Sub
Private Sub btnMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiply.Click
first = txtoutput.Text
txtoutput.Clear()
oper = "*"
End Sub
Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click
first = txtoutput.Text
txtoutput.Clear()
oper = "/"
End Sub
Private Sub btnSqrt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSqrt.Click
first = txtoutput.Text
txtoutput.Clear()
oper = "s"
End Sub
Private Sub btnPercent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPercent.Click
first = txtoutput.Text
oper = "%"
End Sub
End Class
Comment