Answer the question
In order to leave comments, you need to log in
How to make the textbox show the whole c# calculation example in the calculator?
Hello!
I'm writing a calculator on c# windows forms and ran into a problem that when I enter the first number and click on the plus, the first number disappears. I need to show all the calculations in the textbox, i.e. 1 + 2
The code on the "+" button
n = 1;
c1 = Convert.ToDouble(TextBox1.Text);
TextBox1.Text = "";
if (n == 1)
{
c2 = Convert.ToDouble(TextBox1.Text);
c3 = c1 + c2;
TextBox1.Text =Convert.ToString (c3);
}
Answer the question
In order to leave comments, you need to log in
Write the text in the text field, and parse the expression into a separate structure (AST or polis). Count by pressing =. Don't mix calculation logic and UI output.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question