Quote:
> I am building a mapping utility that reads data from an excel file and
> completes a set of processes.
> Since columns in the excel sheet may vay in positions, my mapping tool
> allows me to identify the column.
> Sometimes the data i require comes in from two columns. Therefore while
> mapping I can specify A+B
> Like NetSalary + Tax = Gross.
> Is there any object or function that allows me to evaluate a string
> expression?
> Thanks,
> Nasim
Nasim,
You might try something like this...
You could build a dll using jscript and then reference it from your project.
It would look something like:
// JScript source code
class EvalClass
{
function Evaluate(expression)
{
return eval(expression);
}
Quote:
}
you will have to build this from the command line:
jsc /target:library evaluator.js
Then you can reference the resulting evaluator.dll and Microsoft.JScript.dll
in your VB project. You could then call the function like this:
Dim ec As New EvalClass()
Dim expr As String = "12 + 3 * 10"
Dim res As Double = CType(ec.Evaluate(expr), Double)
Console.WriteLine("{0} = {1}", expr, res)
This way you don't have to use COM interop... You can stay right in the .net
world :)
HTH,
Tom Shelton