DIAdem Help

Method: Rnd for VBS

  • Updated2024-09-12
  • 1 minute(s) read

Method: Rnd for VBS

Generates a random number.

vRnd = Object.Rnd(number)
ObjectVBS
Object with this method. You do not need to specify this object.
numberVariant
Specifies how the Rnd method generates the random number. If the value is smaller than or equal to 0, the Rnd method always generates the same random number. If you do not enter the value, or if the value is greater than 0, the Rnd method generates the next random number.
vRndVariant
Receives the random number which is greater than or equal to 0 and less than 1. You should call the Randomize method before calling the Rnd method. If you do not call Randomize, the Rnd method always generates the same random number sequence when called.

The following example generates random numbers in the range between LowerBound to UpperBound:

Function RndRange(LowerBound, UpperBound)
  Call Randomize   ' Initialize random-number generator.
  RndRange = Int((UpperBound - LowerBound + 1) * Rnd + LowerBound)
End Function

See Also

Objects Overview

Related Topics

Randomize | Rnd