Vbs Tutorial: function-eval function

Source: Internet
Author: User

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  

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.