newbie REALbasic question (random numbers) 
Author Message
 newbie REALbasic question (random numbers)

rnd*(max-min)+min

 --------------------------------------------------------
| Adam Robinson         | www.realbasic.com              |
| REALsoftware Support  | www.free-host.com/realweb      |

|--------------------------------------------------------|
|                    Try REALbasic!                      |
|           True RAD for the Mac and Windows!            |
 --------------------------------------------------------

Quote:

> Organization: http://www.*-*-*.com/
> Newsgroups: comp.lang.basic.realbasic
> Date: Wed, 03 Nov 1999 00:23:47 -0700
> Subject: newbie REALbasic question (random numbers)

> 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)?



Sun, 21 Apr 2002 03:00:00 GMT  
 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/    _/   _/  _/   _/_/_/  _/   _/    


Sun, 21 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. random numbers ( newbie question )

2. Newbie question: Random numbers

3. Newbie question: How do I generate random numbers?

4. Newbie question # Is there a random number generator for TCL

5. Newbie question: random numbers in tcl

6. Newbie Question: Random number generator

7. Random Number Generator to produce SAME random number from 12:00am-11:59pm

8. Newbie Question: Realbasic Question

9. random number generation: the newbie asks for advice

10. newbie: random number?

11. random number generation: the newbie asks for advice

12. newbie question - what is realbasic - from a windows programmer

 

 
Powered by phpBB® Forum Software