VBS TUTORIAL: function-eval function _vbs

Source: Internet
Author: User

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  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.