How to do MSAccess EVAL() function in VB6 and VB.net? 
Author Message
 How to do MSAccess EVAL() function in VB6 and VB.net?

I have one Access applications using EVAL() function and I would like to
know if there is an EVAL() function available in VB6 or VB.net.

EVAL() is an evaluate expression function like EVAL('1+2') will get 3.

Thank you,
Rakkiat




Sat, 14 May 2005 13:38:23 GMT  
 How to do MSAccess EVAL() function in VB6 and VB.net?
From VB6, Surely that the scripting can help you.

Dim oSC As ScriptControl
Dim iVal As Integer
Set oSC = New ScriptControl
oSC.Language = "VBScript"

Dim toexe As String
toexe = "4*5"
iVal = oSC.Eval(toexe)

MsgBox iVal, vbOKOnly, "Value of iVal"
HTH

ric Moreau, MCT, MCSD
Conseiller principal / Senior consultant
Concept S2i inc. (www.s2i.com)


Quote:
> I have one Access applications using EVAL() function and I would like to
> know if there is an EVAL() function available in VB6 or VB.net.

> EVAL() is an evaluate expression function like EVAL('1+2') will get 3.

> Thank you,
> Rakkiat





Sat, 14 May 2005 18:57:16 GMT  
 How to do MSAccess EVAL() function in VB6 and VB.net?
To get Eval functionality in .NET, the general approach is to call
JavaScript from your VB.NET project. The following should explain the
process:

Build an Evalute Function
=================
One of the more useful features in prior versions of Visual Basic was the
Eval() function. Eval would evaluate the supplied string and return a
result. This resulted in the ability to evaluate arbitrary statements at
runtime. Unfortunately, neither C# nor Visual Basic .NET have the same
functionality.

Fortunately, the power of .NET, specifically with the ability to call
components authored in other .NET languages makes this fairly simple to
implement. Our first piece of the puzzle is JScript.NET, the .NET version of
javascript. JScript.NET does include an Eval function. The question is how
to get to that function from our C# or Visual Basic .NET projects.

To build your own Eval equivalent, follow these steps.

Step 1: Create a JScript Wrapper DLL
-------------------------------------------
1. Open Notepad and type in the following code:

class JScriptEval
{
   function Evaluate(evalString : String)
   {
      return eval(evalString);
   }

Quote:
}

2. Save the file as jScriptEval.js and close NotePad.

3. Compile the file using the .NET JavaScript compiler. The following
command line shows how to do this. Note that your path will need to the
directory where the compiler lives. Typically, this is something like:
C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705

    jsc /t:library jScriptEval.js

4. If everything worked according to plan, your directory should now contain
a file called jScriptEval.dll.

Step 2: Create References in your Visual Studio .NET project
-----------------------------------------------------------------
1. Back in your Visual Basic.NET or C# project, create a reference to your
new DLL. To do this, right-click on your project, in the Solution Explorer,
Select the .NET tab, press the Browse button to locate JScriptEval.DLL and
press [OK]

2. You will also need a reference to the Microsoft JScript library. This is
typically located in
c:\windows\microsoft.net\framework\v1.0.3705\Microsoft.JScipt.dll.

Step 3: Test your new eval code
Test your eval library like this:

        Dim j As New JScriptEval()
        Dim s1 As String = "1 + 2 * 3"
        MsgBox(j.Evaluate(s1))

Security Issues
---------------
You should be aware that using Eval statements can lead to potential
security risks. Eval can execute just about any program code. There are two
ways to minimize this. First, you can use a regular expression evaluator to
make sure that the string passed to Eval contains only letters, operators
and numbers, not words. Secondly, consider using .NET security features to
disallow any potentially dangerous operations before code is executed by
Eval.

Hope this helps,
----------------------------------------
Dan Haught, FMS Inc.
- Total .NET SourceBook: The ULTIMATE .NET code library
- Total .NET XRef: Real: time .NET code cross reference
- Total .NET Analyzer: Analyze .NET code for performance and errors
Download today at: www.fmsinc.com/dotnet
----------------------------------------


Quote:
> I have one Access applications using EVAL() function and I would like to
> know if there is an EVAL() function available in VB6 or VB.net.

> EVAL() is an evaluate expression function like EVAL('1+2') will get 3.

> Thank you,
> Rakkiat





Sat, 14 May 2005 21:51:10 GMT  
 How to do MSAccess EVAL() function in VB6 and VB.net?
I got this from the Trigeminal Software site a while back (for VB6 or
VB5).

Attribute VB_Name = "basExecString"
'------------------------------------------
'   (c) 1999 Trigeminal Software, Inc.  All Rights Reserved
'------------------------------------------
Option Compare Text
Option Explicit
Public strFoo As String

Declare Function EbExecuteLine Lib "vba6.dll" _
 (ByVal pStringToExec As Long, ByVal Foo1 As Long, _
  ByVal Foo2 As Long, ByVal fCheckOnly As Long) As Long

' For VB5 IDE
'Declare Function EbExecuteLine Lib "vba5.dll" _
 (ByVal pStringToExec As Long, ByVal Foo1 As Long, _
  ByVal Foo2 As Long, ByVal fCheckOnly As Long) As Long

' FOR Access 97/VBE.dll clients like Word 97 and Excel 97
'Declare Function EbExecuteLine Lib "vba332.dll" _
 (ByVal pStringToExec As Long, ByVal Foo1 As Long, _
  ByVal Foo2 As Long, ByVal fCheckOnly As Long) As Long

Function FExecuteCode(stCode As String, Optional fCheckOnly As
Boolean) As Boolean
  FExecuteCode = EbExecuteLine(StrPtr(stCode), 0&, 0&,
Abs(fCheckOnly)) = 0
End Function

--
Paul Thornett


Quote:
> I have one Access applications using EVAL() function and I would
like to
> know if there is an EVAL() function available in VB6 or VB.net.

> EVAL() is an evaluate expression function like EVAL('1+2') will get

3.


Sun, 15 May 2005 07:51:00 GMT  
 How to do MSAccess EVAL() function in VB6 and VB.net?
Hi, tray with MSSCRIPT.OCX.



Quote:
> I have one Access applications using EVAL() function and I would like to
> know if there is an EVAL() function available in VB6 or VB.net.

> EVAL() is an evaluate expression function like EVAL('1+2') will get 3.

> Thank you,
> Rakkiat





Tue, 14 Jun 2005 02:11:12 GMT  
 How to do MSAccess EVAL() function in VB6 and VB.net?
If its for a VB add-in, you can use the following code:

http://trigeminal.com/codes.asp?ItemID=6

--
MichKa

This posting is provided "AS IS" with
no warranties, and confers no rights.



Quote:
> Hi, tray with MSSCRIPT.OCX.



> > I have one Access applications using EVAL() function and I would like to
> > know if there is an EVAL() function available in VB6 or VB.net.

> > EVAL() is an evaluate expression function like EVAL('1+2') will get 3.

> > Thank you,
> > Rakkiat





Tue, 14 Jun 2005 04:13:29 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How to do MSAccess EVAL() function in VB6 and VB.net?

2. Eval function in VB .Net and C#

3. How to do MSAccess EVAL() function in VB6 and VB.net?

4. Eval Function in VB.NET

5. EVAL function in VB.NET - where is it?

6. Does VB.NET has Eval Function?

7. Eval Function in VB.NET

8. VB6 Equivalent of VBA Eval() function ?

9. Eval() in VB.NET ??

10. JScript.Eval in VB.NET

11. Eval / Execute in vb.NET

12. execute a variable as a function/sub procedure (like eval function in java(script))

 

 
Powered by phpBB® Forum Software