Gmoney
asked on
How to obtain a ramdom number between 1 and 50
How can I obtain a random number between 1 and 50?
Remeber to put Randomize on before the line:
i = Int(Rnd() * 50) + 1
cheers
i = Int(Rnd() * 50) + 1
cheers
Hi,
U can use the following function to get randam number between 1 & 50.
Pass the number 1 & 50 to the following function, the function will return u the random numbers.
Public Function CreateRandNumber(int1stnum
Randomize Timer
CreateRandNumber = Int(Rnd * (int2ndnumber - int1stnumber)) + int1stnumber
End Function
CHEERS,
Fathima
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
? i didn't see any posts when i started answering lol
hi,
U can use the code
Randomize
dim rNo
rNo=CInt(Rnd()*50) +1
this results in the variable rNo set to a random number (not a decimal or float). if u want in decimal u donot put 'CInt'.
BYE.
U can use the code
Randomize
dim rNo
rNo=CInt(Rnd()*50) +1
this results in the variable rNo set to a random number (not a decimal or float). if u want in decimal u donot put 'CInt'.
BYE.
ASKER
Thanks for your help
Int(Rnd() * 50) + 1
and you'll be happy !
Andy