Hi, first off I'd like to say that this is my first post here. I just finished typing up a long explanation of my problem. And when I submitted it, I wasn't logged in anymore, so I logged in, but then subsequently lost my entire post. All I can say is that is VERY frustrating. Other than that, glad to be here.
I am a student trying to build a working calculator like the windows calculator. Let me say that I have definitely put alot of time into this already and I can't figure it out. I spent around a whole day on this one piece of logic. I have no problem doing 1+1 = 2 but when it comes to doing 1*1*1 = 3 I am encountering some logic trouble.
My code takes the first value entered by the user when the user clicks the plus button and adds it to my variable Operand2. From there, I set Operand1 = operand1 + operand2. With this logic I can add numerous time before hitting the equals button.
That logic works great for the plus button, but when it comes to the subtract, multiply, and divide button, I am running into trouble because 0+1= 1 so that works great. But 0*1=0 and I need it to equal 1, because operand 1 should be equal to the product of operand 1 and 2 so that I can multiply numerous times before hitting the equal button. I hope I've been able to explain my dillema well enough.
Here is my Code, any insights you have would be GREATLY appreciated.
In my btnAdd event handler
Calc.operand2 = convert.ToDouble(me.txtInput.text)
Calc.operator = "add"
In my Calc Class
Public Function Result() As Double
Select Case sOperator
Case is = "add"
Result = dOperand1 + dOperand2
dOperand1 = Result
In my btnEquals event handler
Calc.Operand2 = Convert.ToDouble(Me.txtInput.text)
Me.txtInput.text = Calc.Result.ToString
Calc.Operand1 = Nothing
I hope this post wasn't too long and confusing. :o Thanks for reading