There is already a great resource here on the rnd function.
I will not cover this, what I will look at is the RANDOM class.
One issue I have bumped into before needing a random integer value that is between 2 values (a high and a low).
Using the rnd function usually requires that you convert part of the double to be your Whole number and then see if it is larger or smaller than your min or max values, and if it isn't calling it again until you hit a valid return.
I.E. I have 275 images and want to randomly get 1 of the images. Picking a 3 digit section of the returned double will have about a 60% chance of being too great!
This is where the RANDOM class comes in!
Code:
Dim r as Random
msgbox r.Next(1,275)
will return a whole number(integer) between 1 and 275. No testing needed.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.