VBScript Rnd a hanyin a yin a aya a kowa:

A gina a na aya a kowa a hanyin a yin a aya a kowa:

Rnd a hanyin a gina a yin a aya a kowa. a hanyin a aya a kowa a aya a hanyin a yin a aya a kowa, a kowa a hanyin a yin a aya a kowa:

Dinma, dama gina a Rnd a hanyin a ga a aya a hanyin a hanyin a yin a aya a kowa, so a kowa a yin a aya a gina a hanyin a hanyin a yin a aya a kowa:

Dinma, dama gina a Randomize ka a na ga, a ka a yin a yin a aya a tasiya a gina a yin a aya a kowa:

A gina ce ta a yiya nuna za ainiya, ya gina a hanyin a fariya:

Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

Here, upperbound is the upper limit of this range, and lowerbound is the lower limit of this range.

Note:To repeat the random number sequence, call Rnd with a negative value parameter immediately before using the numeric parameter. Using the same number for Randomize cannot repeat the previous random number sequence.

Syntax

Rnd[(number)]
Parameter Description
number

Optional. A valid numeric expression.

If the number is:

  • <0 - Rnd returns the same value each time.
  • >0 - Rnd returns the next number in the sequence.
  • =0 - Rnd returns the last generated number.
  • Omitted - Rnd returns the next number in the sequence.

Instance

Example 1

document.write(Rnd)

Output:

0.7055475

Example 2

If you use the code in Example 1, the same random number will appear repeatedly.

You can use the Randomize statement to generate a new random number every time the page is reloaded:

Randomize
document.write(Rnd)

Output:

0.4758112

Example 3

dim max,min
max=100
min=1
document.write(Int((max-min+1)*Rnd+min))

Output:

71