Click here to Skip to main content
16,005,697 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
hi everyone!!!
i want to do the coding for multisubtraction using equal sign at the last in the calculator..
eg.3-2-1=
please help me out to do this..
Posted
Comments
midnight_ 18-Jul-13 2:07am    
do you mean typing this in a textbox and the equal sign calucates the result?
more information would help.
shipra goyal 18-Jul-13 2:52am    
using mouse numeric buttons are clicked and as soon as we click on equal btn result will be shown..i m able to perform 3-2= but not 4-3-2=.. in this it is only taking 3-2 that is last minus sign..
What have you tried?
shipra goyal 18-Jul-13 2:55am    
minus = true;
plus = false;
mul = false;
div = false;
a =Convert.ToDouble(displaytxtbox.Text);
in equal btn,i write this code..
if (minus)
{
b =a-Convert.ToDouble(displaytxtbox.Text);
displaytxtbox.Text = Convert.ToString(b);
a = 0;

}

i m able to perform 3-2= but not 4-3-2=.. in this it is only taking 3-2 that is last minus sign..
Have you referred any article or this is your own code?
If you have referred an article, then provide the link. Else paste all your code.

 
Share this answer
 
All you need is JavaScript eval(): http://www.w3schools.com/jsref/jsref_eval.asp[^].

Got the hint?

—SA
 
Share this answer
 
C#
private void minusbtn_Click(object sender, EventArgs e)
       {
           minus = true;
           plus = false;
           mul = false;
           div = false;
           if (a == 0)
           {
               a = Convert.ToDouble(displaytxtbox.Text);
           }
           else
           {
               a = a - Convert.ToDouble(displaytxtbox.Text);
           }
           showtxtbox.Text = showtxtbox.Text + displaytxtbox.Text + "-";
           displaytxtbox.Text = "";


when equal btn pressed,coding is...

C#
if (minus)
           {
               b =a-Convert.ToDouble(displaytxtbox.Text);
               displaytxtbox.Text = Convert.ToString(b);
               a = 0;

           }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900