Eval evaluates 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 Code code as follows:
Response. Write (Eval_r ("3+2")) ' Output 5
"3+2" is enclosed in quotes, representing a string, but in the Eval "eye", it executes as an expression 3+2.
Execute executes one or more of the specified statements. Multiple statements are separated by a colon (:).
Syntax: Execute statements
Example:
Execute "Response. Write ("abc" ")" ' Output ABC
Copy Code
"Response. Write ("abc") is enclosed in quotes to indicate a string
But in Execute "the eye", treats it as a statement response. Write ("ABC") to perform.
Executeglobal executes one or more specified statements in the global namespace.
Syntax: Executeglobal statement
Example:
Copy Code code as follows:
Dim c
c = "global variable"
Sub S1 ()
Dim c
c = "local variable"
Execute "Response. Write (c) "' Output local variable
Executeglobal "Response. Write (c) "' Output global variable
End Sub
Execute "Response. Write (c) "' Output global variable
Call S1 ()
Variable c is defined both globally and within the scope of the function, where Execute decides whether to use local or global variables in its place, and Executeglobal always only recognize global scope C.
Summarize:
Eval executes only one statement statement can have or can not return a value
Execute executes one or more statements ignoring the return value of the statement
Executeglobal executes one or more statements ignores the return value of a statement global and local variables always use global variables when they have the same name
Attention:
In VBScript "Assignment" and "comparison" are used "=", such as "a=b" can be said to be a B value to a, or to determine whether a and B are equal, then Eval_r ("A=b") is to represent the assignment or comparison operations?
There is a convention that, in Eval, "A=b" always represents a comparison operation and always represents an assignment in both Execute and Executeglobal.