|
-
Jan 10th, 2006, 08:16 PM
#1
Thread Starter
New Member
* By a random number
I was just wondering how you get an equation to be multiplied by a random number..
For example;
Code:
Sum = 1 * 1 * (RANDOM NUMBER)
Label1.Caption = Sum
Thanks ^^
-
Jan 10th, 2006, 08:24 PM
#2
Re: * By a random number
What language are you using?
Bill
-
Jan 10th, 2006, 08:30 PM
#3
Thread Starter
New Member
-
Jan 11th, 2006, 06:10 AM
#4
Re: * By a random number
It depends on the range you wnat the random number to be.
VB Code:
randomize
Sum = 1 * 1 * rnd
Label1.Caption = Sum
Rnd outputs between 0 and 0.9 look into ways of muliplying that to get ranges of random numbers!
-
Jan 11th, 2006, 06:07 PM
#5
Thread Starter
New Member
Re: * By a random number
 Originally Posted by Pino
It depends on the range you wnat the random number to be.
VB Code:
randomize
Sum = 1 * 1 * rnd
Label1.Caption = Sum
Rnd outputs between 0 and 0.9 look into ways of muliplying that to get ranges of random numbers!
Thanks^^
But..(i'v only used vB for a day or two so far), how do i select the range of numbers?
-
Jan 12th, 2006, 06:08 AM
#6
Re: * By a random number
to select range of numbers:
VB Code:
randomize
Sum = 1 * (rnd * [i]myNum[/i])
Label1.Caption = Sum
if myNum = 10, then sum could range from 0 to 9.99. if you want to generate a whole number, use CInt or Clng before the parenthesis.
VB Code:
randomize
Sum = 1 * CLng(rnd * [i]myNum[/i])
Label1.Caption = Sum
Harsh.
-
Jan 12th, 2006, 06:10 AM
#7
Re: * By a random number
Its not so much Vb now, its more mathmatics....
If rnd outputs 0 - 0.9 and you wnat your range to be 0 to 9 (ie 10 numbers) then you just do this,
sum = int(rnd * 10)
Pino
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|