You have two problems: the first is that you are "forcing" click events where you don't need to - a much better solution is to have your click event handlers call a method, and then call the same method from your other code. This separates the user interface from the processing code, which means it becomes a lot easier to change things later.

The second is that what you are trying to do is not really going to work. You give an example of "2+6+9-6*5" as a "multi-operation", but you would need to define what should happen as a result: 55, or -13 before you go any further.

The first result is trivial: each time you get an operator, you evaluate the data before it. So you get

Copy Code

2 2+ Evaluate: 2 == 2 2+6 2+6+ Evaluate: 2 + 6 == 8 8+9 8+9- Evaluate: 8 + 9 == 17 17-6 17-6* Evaluate: 17-6 == 11 11*5 11*5= Evaluate: 11*5 == 55

But for the second one your can't do that because you need to include operator precedence: "*" is "more important" than "+" so you have to evaluate

`(6*5)`

before you can do the rest - and that is a whole load more complicated.What I'd suggest is that you have a look at how other calculators work: not just Calc.EXE, but Microsoft Mathematics as well: Download Microsoft Mathematics 4.0 from Official Microsoft Download Center[^] and work out what you want to achieve before leaping into code as you have done so far!