RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Math.RandomRange Function

Returns a random integer from a specified range.

Pascal
function RandomRange(const AFrom: Integer; const ATo: Integer): Integer;
C++
int RandomRange(const int AFrom, const int ATo);

RandomRange returns a random integer from the range that extends between AFrom and ATo (non-inclusive). RandomRange can handle negative ranges (where AFrom is greater than ATo). 

To initialize the random number generator, add a single call Randomize or assign a value to the RandSeed variable before making any calls to RandomRange. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!