Eval function
Calculates the value of an expression and returns the result.
[Result =]Eval (Expression)
Parameters
Result
Optional. Is a variable used to accept the returned results. If no result is specified, consider usingExecuteStatement.
Expression
Required. It can be a string containing any valid VBScript expression.
Description
In VBScript,X = yThere are two possible interpretations. The first method is the value assignment statementYValueX. The second explanation is testXAndYEqual or not. If they are equal,ResultIsTrueOtherwiseResultIsFalse.EvalThe method always adopts the second explanation, whileExecuteThe first statement is always used.
Note:There is no confusion between this comparison and assignment in Microsoft (r) Visual Basic Scripting Edition, because the assignment operator (=) is different from the comparison operator (=.
The example below illustratesEvalFunction usage:
sub guessanumber dim guess, rndnum = int (100) * RND (1) + 1) Guess = CINT (inputbox ("Enter your guess: ", 0 )) do If eval ( "Guess = rndnum" ) then msgbox "
congratulations! You guessed it! "
exit sub
else
guess = CINT (inputbox ("
sorry, please try again ", 0 ))
end if
loop until guess = 0
end sub