newbie REALbasic question (random numbers)

Most random number generators will give you a random number between 0 and

1, then you can scale that number to the range you want by multiplying it

by the range.

Example, let's say you want a random integer between 5 and 13 (min 5, max

13, range 8):

dim r as integer

r = 5 + ( rnd * 8 )

Hope this helps,

Quote:

> Hi all,

> I've been playing around with the Real Basic demo for a few days.

> Sometimes I get extremely frustrated, but I (barely) understand enough so

> my experimenting has been more fun than not.

> A quick question:

> How do I generate random numbers and then pass that number on to a text

> field? I tried rnd, but it only returns a value of either 0 or 1.

> How can I generate random numbers based on a range I specify? Say I want

> to generate a random number from 1 to 6, or 5 to 13 (or any arbitrary

> range for that matter)?

> Thanks in advance,

____Nicholas C. DeMello, Ph.D., Editor_________________________________

MacTech Magazine, the Journal of Macintosh Technology & Development

http://www.MacTech.com/

_/ _/ _/ _/_/_/ _/ _/

_/_/ _/ _/ _/ _/ _/_/_/

http://www.nick.demello.com/ _/ _/ _/ _/_/_/ _/ _/