I have received couple of mails regarding generating random number in vbscript. So here i am with the post on random number.
There are two ways of generating random numbers in VBScript which are as follows:
There are two ways of generating random numbers in VBScript which are as follows:
1. Using randomize keyword.
'consider the below example of generating a random number between 10 -99, i.e., 2 digit number.
intMaxValue=99 '
intMinValue=10
Randomize 'This will generate a unique number every time
intRndVariable= Int((intMaxValue-intMinValue+ 1) * Rnd +intMinValue)
intRndVariable will hold the random number.
2. Use RandomNumber function
intRandomNumber=RandomNumber(intLoweLimit,Upperlimit)
e.g., a=RandomNumber(10,99)
No comments:
Post a Comment