Re: Random Function



"James" <webmaster@xxxxxxxxxxxxxx> wrote in message
news:1129149210.646071.107510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

> In VB their (sic!) is a function were (sic!) you can generate a random
> number. The only way I know how to do this looks like:
> Ramdomize (sic!)
> Int((Rnd * 9) + 1)
> Surely their (sic!) is a simpler way to do this?

Yes. There is a much more simple way. If you just want the next random
number in the sequence you can simply use:

a = Rnd

The above code will give you the next random number, and it will be in the
range from zero to 1 (but never quite equal to 1). If that's what you want
then fine. However, if you instead want something different (a random "whole
number" in the range from 1 to 9, for example) then you will have to use a
little bit of code (something similar to your example code, perhaps?).

What is your problem with that? Is it "too much typing for you" perhaps, or
is there some other reason you don't like it?

Mike








.



Relevant Pages