hi all :)
I am now working on a calculator that is mimic to windows calculator.
I have the whole thing done except for the percent button. Have looked everywhere and cannot seem to find out how to do it!
can someone help me here??
Here is a peek at some of what I have so far:
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
If Status = False Then
TextBox1.Text = TextBox1.Text + CStr(1)
Else
TextBox1.Text = 1
Status = False
End If
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
If Status = False Then
TextBox1.Text = TextBox1.Text + CStr(2)
Else
TextBox1.Text = 2
Status = False
End If
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
If Status = False Then
TextBox1.Text = TextBox1.Text + CStr(3)
Else
TextBox1.Text = 3
Status = False
End If
End Sub
Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
If Status = False Then
If TextBox1.Text.Length > 0 Then
TextBox1.Text = TextBox1.Text + CStr(0)
End If
End If
End Sub
Private Sub btnDecimal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecimal.Click
If Status = False Then
If TextBox1.Text.Length > 0 Then
TextBox1.Text = TextBox1.Text + CStr(0)
End If
End If
End Sub
Private Sub btnSqrt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSqrt.Click
If TextBox1.Text.Length <> 0 Then
Temp = CDbl(TextBox1.Text)
Temp = System.Math.Sqrt(Temp)
TextBox1.Text = CStr(Temp)
period = False
End If
End Sub
Private Sub btnMR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMR.Click
If btnMemStatus.Text = "M" Then
TextBox1.Text = CStr(Memory)
Status = True
End If
End Sub
Private Sub btnC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnC.Click
TextBox1.Text = ""
Var1 = 0
var2 = 0
[Operator] = ""
period = False
End Sub
Private Sub btnCE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCE.Click
TextBox1.Text = ""
period = False
End Sub
Private Sub btnMC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMC.Click
Memory = 0
TextBox1.Text = Nothing
End Sub
Private Sub btnMS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMS.Click
If TextBox1.Text.Length > 0 Then
Memory = Memory - CDbl(TextBox1.Text)
btnMemStatus.Text = "M"
End If
End Sub
Private Sub btnMPlus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMPlus.Click
If TextBox1.Text.Length > 0 Then
Memory = Memory + CDbl(TextBox1.Text)
btnMemStatus.Text = "M"
End If
End Sub
Private Sub btnPlusMinus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlusMinus.Click
If Status = False Then
If TextBox1.Text.Length > 0 Then
Var1 = -1 * CDbl(TextBox1.Text)
TextBox1.Text = CStr(Var1)
End If
End If
End Sub
Private Sub btnAddition_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddition.Click
If TextBox1.Text.Length <> 0 Then
If [Operator] = "" Then
Var1 = CDbl(TextBox1.Text)
TextBox1.Text = ""
Else
Calculate()
End If
[Operator] = "Add"
period = False
End If
End Sub
Private Sub btnEquals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEquals.Click
If TextBox1.Text.Length <> 0 AndAlso Var1 <> 0 Then
Calculate()
[Operator] = ""
period = False
End If
End Sub
Private Sub btnOneTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOneTime.Click
If TextBox1.Text.Length <> 0 Then
Temp = CDbl(TextBox1.Text)
Temp = 1 / Temp
TextBox1.Text = CStr(Temp)
period = False
End If
End Sub
Private Sub btnSubtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubtract.Click
If TextBox1.Text.Length <> 0 Then
If [Operator] = "" Then
Var1 = CDbl(TextBox1.Text)
TextBox1.Text = ""
Else
Calculate()
End If
[Operator] = "Sub"
period = False
End If
End Sub
Private Sub btnMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiply.Click
If TextBox1.Text.Length <> 0 Then
If [Operator] = "" Then
Var1 = CDbl(TextBox1.Text)
TextBox1.Text = ""
Else
Calculate()
End If
[Operator] = "Mult"
period = False
End If
End Sub
Private Sub btnPercent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPercent.Click
End Sub
Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click
If TextBox1.Text.Length <> 0 Then
If [Operator] = "" Then
Var1 = CDbl(TextBox1.Text)
TextBox1.Text = ""
Else
Calculate()
End If
[Operator] = "Div"
period = False
End If
End Sub
End Class