Connecting Tech Pros Worldwide Help | Site Map

EVAL function

bill
Guest
 
Posts: n/a
#1: Apr 26 '06
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




Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#2: Apr 26 '06

re: EVAL function


"bill" <belgie@datamti.com> schrieb:[color=blue]
> 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[/color]

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/>

Tom Shelton
Guest
 
Posts: n/a
#3: Apr 26 '06

re: EVAL function



bill wrote:[color=blue]
> 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[/color]

Bill here is a possible solution:

http://groups.google.com/group/micro...e=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]

Closed Thread