Bookshelf Home | Contents | Index | PDF |
Siebel VB Language Reference > VB Language Reference > Rnd FunctionThis standard VB function returns a single-precision random number between 0 and 1. SyntaxReturnsA single-precision pseudo-random number between 0 and 1. UsageIf number is less than zero, the specified number is used as the seed for a pseudo-random number, which is generated every time the Rnd function is executed. If number is greater than zero, or is omitted, Rnd generates a sequence of pseudo-random numbers, in which each execution of the Rnd function uses the next number in the sequence. If number is equal to zero, Rnd uses the number most recently generated. The same sequence of random numbers is generated whenever Rnd is run, unless the random number generator is re-initialized by the Randomize statement. ExampleThis example generates a random string of characters within a range. The Rnd function is used to set the range between lowercase a and z. The second For...Next loop is to slow down processing in the first For...Next loop so that Randomize can be seeded with a new value each time from the Timer function. Sub Button_Click See AlsoExp Function |
Siebel VB Language Reference |