Hi. I'm wondering if it's possible to use the Win CalcManager as an expression parser. I need a tool that will parse math expressions and calculate an answer. Is this tool capable of doing that? If so, are there any examples of using it that way?
Thanks.
Hi,
Not sure what you mean by "parse math expressions and calculate an answer". What kind of math expressions are you talking about here?
Are you talking about using some custom syntax here?
If you expression are valid CalcManager formulas, then you could use the Calculate method.
For example:
UltraCalcValue calcValue = this.ultraCalcManager1.Calculate("2+2"); Debug.WriteLine(calcValue.Value);
Mike,
Thanks for the input. It looks like the Win CalcManager may evaluate formulas as I'm hoping. Here's a second question for you.
Is it possible to configure the WinCalcManager to calculate formulas containing non-English formatted numbers? For example, will it calculate something like "2,5 + 4,55 + 1,33"? If so, what settings do I need to change? The default settings don't seem to handle non-English number formats.
No, formulas need to be in the Invariant culture. Normally, this is not a problem. If your application is performing calculations on numeric values, then those values are the same regardless of the current culture. But if you or your users are going to be creating literal strings and passing them in to the Calculate method, then they will need to use the Invariant culture.
Of course, if your numeric values are stored as numbers, then you can call the ToString method on those variables and specify the Invariant culture to the ToString method.