Home All Groups Group Topic Archive Search About
Author
26 Apr 2006 8:37 PM
bill
In VB.NET 2005, is there an equivalent of the EVAL function available in
MSAccess and javascript?

I need a way to pass a dynamically generated string (like "2+2") to a
function and return 4.

EVAL("2+2") will return 4

Thanks
Bill

Author
26 Apr 2006 9:22 PM
Herfried K. Wagner [MVP]
"bill" <bel***@datamti.com> schrieb:
> In VB.NET 2005, is there an equivalent of the EVAL function available in
> MSAccess and javascript?
>
> I need a way to pass a dynamically generated string (like "2+2") to a
> function and return 4.
>
> EVAL("2+2") will return 4

Hand-made:

MathLib
<URL:http://www.palmbytes.de/content/dotnet/mathlib.htm>

Dynamic compilation:

Build a Custom .NET "EVAL" Provider
<URL:http://www.eggheadcafe.com/articles/20030908.asp>

Runtime Compilation (A .NET eval statement)
<URL:http://www.codeproject.com/dotnet/evaluator.asp>

Evaluation of numeric expressions using J#:

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.csharp/msg/9e95759b54a323a7>

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
26 Apr 2006 9:27 PM
Tom Shelton
bill wrote:
> In VB.NET 2005, is there an equivalent of the EVAL function available in
> MSAccess and javascript?
>
> I need a way to pass a dynamically generated string (like "2+2") to a
> function and return 4.
>
> EVAL("2+2") will return 4
>
> Thanks
> Bill

Bill here is a possible solution:

http://groups.google.com/group/microsoft.public.dotnet.languages.vb/msg/cdd5d864296563a7?q=+%22jscript%22+group:microsoft.public.dotnet.languages.*+author:Tom+author:Shelton&hl=en&lr=&ie=UTF-8&oe=UTF-8&rnum=1

This was a very simple example...  Please be aware that this will allow
you to run arbitray bits of JScript code - so you might want to put
some kind of verification on the actual expresions passed.  You could
probably use a regex to make sure that the expression was really not
code :)

--
Tom Shelton [MVP]