Link to home
Start Free TrialLog in
Avatar of Gmoney
Gmoney

asked on

How to obtain a ramdom number between 1 and 50

How can I obtain a random number between 1 and 50?
Avatar of Fischermaen
Fischermaen

of course, try

Int(Rnd() * 50) + 1

and you'll be happy !

Andy
Avatar of Ryan Chong
Remeber to put Randomize on before the line:
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(int1stnumber As Integer, int2ndnumber As Integer) As Integer

Randomize Timer
CreateRandNumber = Int(Rnd * (int2ndnumber - int1stnumber)) + int1stnumber

End Function


CHEERS,
Fathima
ASKER CERTIFIED SOLUTION
Avatar of PlanetCpp
PlanetCpp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
? 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.
Avatar of Gmoney

ASKER

Thanks for your help