Sorry about that, here's the code:
------------------------------------------------------------------------------
using System;
using Microsoft.JScript;
using Microsoft.JScript.Vsa;
namespace VPDBUtils
{
public class JScriptEvaluator
{
private static VsaEngine vsaEngine;
public static void Initialize()
{
vsaEngine = VsaEngine.CreateEngine();
}
public static void Close()
{
if (vsaEngine != null)
{
vsaEngine.Close();
}
}
private static object EvaluateString(string sStringToEvaluate)
{
return Eval.JScriptEvaluate(sStringToEvaluate, vsaEngine);
}
internal static double EvaluateStringAsDouble(string sStringToEvaluate)
{
return System.Convert.ToDouble(EvaluateString(sStringToEv aluate));
}
}
}
------------------------------------------------------------------------------
First you call the static Initialise, the pass your string to
EvaluateStringAsDouble() and it gives you the result back as a double.
"Amiram Korach" <Am**********@discussions.microsoft.com> wrote in message
news:64**********************************@microsof t.com...
You can always work hard and write it yourself, but I think you are not
the
first to meet this. I found something in CodeProject:
http://www.codeproject.com/vb/net/ma..._evaluator.asp
I you search yourself, I'm sure you'll find more.
"Juan" wrote:
If I have a string with a valid math expression like " (2 + 28)/1", how
can
I evaluate it?
Thanks,
Juan.