Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
how to handle error while using webCalmanager.calculate
posted

Hi

I have a question about how to check the formula string is in the corrected format that the method "calculate" can calculate it.

for example, if i put the formula string like 

answer = uc1.Calculate("+").ToDecimal()           '''''''''condition 1

instead of     

answer = uc1.Calculate("2+3").ToDecimal().       '''''''''condition 2

how can i set answer = 0 on event like condition1

 

Parents
  • 364
    posted

    Hi,

    I'm not sure if you have already figured this out, but since there is no response from anyone (in almost a year), and your question actually helped me solve an issue I was having, I thought I would try an answer your question, if not to help you, to maybe help someone else who has this issue in the future.

    I solved this by wrapping your code in a try{}..catch{} function, like this:

    try

    {

        answer = uc1.Calculate("+").ToDecimal();

    }

    catch (Exception ex)

    {

        answer = 0;

    }

    I hope this help you or anyone else who comes across this issue in the future.

    Mark

Reply Children
No Data