Ive been trying for a while to make a calculator in Microsoft Visual Web Developer 2008 Express but cant figure it out or come close.
I have all the buttons set up and ID as Button1, Button2,etc. Same with the add,minus,divide,multiply buttons. The tricky part is theres 4 labels and when you click the numbers, the numbers have to appear in the first label and stay there. then you click the add,minus,mult,div button and that appears in the second label and stays there untill cleared. then the next buttons clicked appear in the third label and the anser appears in the 4th label when the enter button is clicked.
We will clear lblResult label at the beginning of each new calculation. This is necessary because the “=” button click event will place the result in lblResult and we don’t want it to show during entry of the next calculation parameters.
Additionally, a blank lblOperator will be the signal that we are entering the first number and not the second.
The code should act as follows.
If there is nothing in lblFirstNumber.Text then
clear lblResult.Text
End If
If there is nothing in lblSecondNumber.Text then
append the number of the key just pressed to whatever is already in lblFirstNumber.Text
Else
append the number of the key just pressed to whatever is already in lblSecondNumber.Text
End If= Button Click Event
how do i write this^ code?
Execute the code only if both lblFirstNumber and lblSecondNumber contain text.
Create variables of type double to hold the first number, the second number, and the result of the calculation.
Instantiate a new calculator object.
Perform the appropriate calculation by calling a function of the calculator class based on the value in lblOperator.Text.
Concatenate the values in lblFirstNumber.Text, lblOperator.Text, and lblSecondNumber.Text with the equal sign and the value returned from the calculator function. Remember to convert the result of the calculation to a string value. Store the string in lblResult.Text.
Clear lblFirstNumber.Text, lblOperator.Text, and lblSecondNumber.Text by setting their values to “”.
Operator Button Click Events
The click events for the + - * and / keys are similar. Set lblOperator.Text equal to symbol for the operation. For example, the click event for the + key would have code that looks like
lblOperator.Text = “+”
Note that this is the value that will be checked when deciding which function of the calculator class to call in the = button click event.
Clear Button Click EventSet the Text property of lblFirstNumber, lblSecondNumber, lblOperator, and lblResult to “”.
thanks for any help, i really appreciate it