Eval calculates the value of an expression and returns the result.
Syntax: [result =] eval_r (expression_r)
Expression_r is a string of any valid VBScript expression.
Example:
Copy codeCode: response. Write (eval_r ("3 + 2") 'output 5
"3 + 2" is enclosed in quotation marks, indicating that it is a string, but in the Eval "eyes", it is executed as an expression 3 + 2.
Execute to Execute one or more specified statements. Multiple statements are separated by colons.
Syntax: Execute statements
Example:
Execute "response. Write (" abc "") "'output abc
Copy code
"Response. Write (" abc "") "is enclosed in quotation marks, indicating a string.
But in the eyes of Execute, it is executed as a statement response. Write ("abc.
ExecuteGlobal executes one or more specified statements in the global namespace.
Syntax: ExecuteGlobal statement
Example:Copy codeThe Code is as follows: dim c
C = "global variables"
Sub S1 ()
Dim c
C = "local variables"
Execute "response. Write (c)" 'output local variables
ExecuteGlobal "response. Write (c)" 'output global variables
End sub
Execute "response. Write (c)" 'output global variables
Call S1 ()
Variable c is defined both globally and within the function range. Execute determines whether to use local variables or global variables based on its location, executeGlobal always recognizes only the c in the global range.
Summary:
Eval can execute only one statement or return no value.
Execute runs one or more statements to ignore the return value of the statement.
ExecuteGlobal executes one or more statements to ignore the return value of the statement. When the global variable and the local variable have the same name, the global variable is always used.
Note:
In VBScript, "value assignment" and "comparison" both use "=". For example, "a = B" can be used to assign the value of B to, it can also be said to judge whether a and B are equal, so does eval_r ("a = B") indicate a value assignment or a comparison operation?
In Eval, "a = B" always indicates a comparison operation. In Execute and ExecuteGlobal, it always indicates a value assignment.