you could call out to a JScript.NET module that then calls the built-in
JScript function, eval().
example:
EvalUtil.jsc::
===================================
import System.Console;
package Ionic
{
class JsUtil
{
public static function Eval(expr : String) : String
{
System.Console.WriteLine("expression: {0}", expr);
var result : String = eval(expr);
System.Console.WriteLine("result: {0}", result);
return result;
}
}
}
===================================
Eval.cs::
===================================
public class Test {
public static void Main() {
string str1= "((10*80) / 100)";
Ionic.JsUtil.Eval( str1 );
string str2= "(240/80)";
Ionic.JsUtil.Eval(str2);
Ionic.JsUtil.Eval(str1 + " - " + str2);
}
}
I don't know if it is possible to call directly into the JScript.NET runtime
from {vb, C#, J#, etc} without building the wrapper in JScript.
"Gálos Zsuzsa" <ga*****@chello.hu> wrote in message
news:ek**************@TK2MSFTNGP10.phx.gbl...
Hi all,
I need to calculate Formulas.
For example:
dim strFormula as string="25*(12-6)"
I ned a DotNet Function to calculate this Formula (25*(12-6)=150):
dim dblValue as double = 150
Does anyone know how can i do this?
thanks a lot
Zsuzsa