Eval function
Evaluates the value of an expression and returns the result.
[result = ]Eval(expression)
Parameters
Result
Options available. is a variable that accepts the returned results. If you do not specify a result, you should consider using the Execute statement instead.
Expression
Required option. Can be a string that contains any valid VBScript expression.
Description
In VBScript,x = y can be interpreted in two ways. The first method is an assignment statement that assigns the value of y to x. The second explanation is to test whether x and y are equal. If equal, result is True, otherwise result is False. The Eval method always takes the second explanation, and the Execute statement always takes the first one.
Note This comparison is not confused with assignment in Microsoft (R) Visual Basic scripting Edition because the assignment operator (=) differs from the comparison operator (= =).
The following example illustrates the use of the Eval function:
Sub guessanumber Dim Guess, Rndnum rndnum = Int ((m) * RND (1) + 1) Guess = CInt (InputBox ("Enter Your Guess: ",,, 0)" Do If Eval ( "Guess = rndnum" ) Then MsgBox " congratulate you! You guessed it!
Exit Sub
Else
Guess = CInt (InputBox ("
Sorry, please try again ,, 0))
End If
Loop Until Guess = 0
End Sub