Knowledge Base Articles » KB100207: How to Evaluate a VBScript Expression at Run Time.
function and the Execute
statement which are
new features in VBScript 5.0 are closely related. They both can be used
to evaluate, or execute, a VBScript expression at run time.
takes any valid VBScript expression as its argument.
It is designed to be used in the form:
result = Eval(strValidVBScriptExpression)
If the argument is a valid VBscript expression, then Eval
the code and sets result equal to the return value.
statement essentially behaves in the same way as
, but there are two crucial differences. First, Execute
is used to execute expressions that DO NOT return a value. It is of
Execute("strFact = ""DevGuru is great!""")
Second, if the argrument is of the form, a = b, then it is treated
as an assignment operation where a is set equal to b. In contrast, Eval
treats the form, a = b, as an equality comparison. It returns true if
the comparison is true. Otherwise, it returns false.