VBS Tutorial: VBScript statement-Randomize statement

Source: Internet
Author: User

Randomize statement

Initialize the random number generator.

Randomize[Number]

NumberA parameter can be any valid numeric expression.

Description

RandomizeUseNumberParameter initializationRndThe random number generator of the function, which is assigned a new seed value. If omittedNumber, Use the value returned by the system timer as the new seed value.

If you do not useRandomize, The first callRndWhen a function (without parameters) is used, it uses the same number as the seed value, and then uses the final generated value as the seed value.

Note:To repeat the sequence of random numbers, call it using numerical parameters.RandomizePreviously, it was called immediately with a negative value ParameterRnd. Use the sameNumberValueRandomizeThe previous random number sequence cannot be repeated.

The following example illustrates how to useRandomizeStatement:

Dim MyValue, ResponseRandomize'Initialize the random number generator.Do Until Response = vbNoMyValue = Int (6 * Rnd) + 1 )'Generate1To6Between.MsgBox MyValueResponse = MsgBox ("Roll again? ", VbYesNo)Loop

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.