+ Start a Discussion
Satyajit SinghSatyajit Singh 

I want to calculate an exression String A = (10*10+5).

If I enter a value (10*10+5) in a text field, then how can I convert the String in a mathemetical format and compute.
This is an example. The text can contain any maths operator.

Niket SFNiket SF
Hello Satyajit,

 You have to parse the string first with the help of the mathematical signs (+,-,*,/ ...) (Will be considered as a string)

 - After that you have to convert string in to the integer . 
- We have to store sequence of the (special caracter ) 
- as per the sequence you can use maths operation in controller.

Note => May be this functionality can be achived by using some jQuery or EXtJS work as well. Just check that as well.

John PipkinJohn Pipkin
I don't think you can do this with Apex easily. There are a couple of options for javascript. Check out http://silentmatt.com/javascript-expression-evaluator/

Hope that helps
Niket SFNiket SF
Recently I did the same thing by using jQuery.