Sometimes required generate a random number between given range.
There is a class RandomGenerate for generate random numbers.
See below example, My requirement generate random numbers with 9 digits .
static void AXExplorer_Randomnumber(Args _args)
{
RandomGenerate randomGenerate;
int randomNumber;
randomGenerate = RandomGenerate::construct();
randomGenerate.parmSeed(new Random().nextInt());
randomNumber = RandomGenerate.randomInt(100000000, 999999999); // need to specify range
info(strFmt("%1", randomNumber));
}
No comments:
Post a Comment