Executes a specified JavaScript statement.
Required. String containing the statement being executed.
Executes a specified JavaScript statement.
Visual Basic |
---|
Public Sub ExecuteStatement( _ ByVal Statement As String _ ) |
Required. String containing the statement being executed.
Execute a statement within the context of the global module.
There are four different ways to execute a program using JavaScriptX. The simplest way is with the Eval method. This method returns the value of the specified expression. For instance x = JavaScriptX.Eval(“1+2”) will assign a value of 3 to the variable x. The Eval method can also reference functions and variables that are defined in either the global module or the local module, if the method was invoked from a local module. It also can access any resource declared as public in any module.
You can also execute a single statement by using the ExecuteStatement method, as in: JavaScriptX.ExecuteStatement(“alert('Hello');"). This method works just like the Eval method and can access resources in the module it was declared, in public variables declared in any module, and in the global module.
Another way to execute script code is to use the Run method. This method allows you to execute any subroutine declared in the JavaScriptX. The subroutine may call any other subroutine or access any objects according to the rules that are used to create modules. You also can specify an array containing the parameters to be passed to the subroutine.
The AddCode method adds a block of code of code to JavaScriptX. During this process, the syntax of the code is checked, and the first error found will trigger the Error event.
NOTE: When you run a script using the JavaScriptX, you can’t change most of the properties or use any of the methods until the script has finished.
WARNING: Be sure to keep a separate copy of the code to which you added the JavaScriptX. There is no way to retrieve code from the control once it has been added.