I was just wondering how you get an equation to be multiplied by a random number..
For example;
Thanks ^^Code:Sum = 1 * 1 * (RANDOM NUMBER)
Label1.Caption = Sum
Printable View
I was just wondering how you get an equation to be multiplied by a random number..
For example;
Thanks ^^Code:Sum = 1 * 1 * (RANDOM NUMBER)
Label1.Caption = Sum
What language are you using?
Bill
Sorry, Visual Basics 6.0
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^^Quote:
Originally Posted by Pino
But..(i'v only used vB for a day or two so far), how do i select the range of numbers?
to select range of numbers:
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 * (rnd * [i]myNum[/i]) Label1.Caption = Sum
Harsh.VB Code:
randomize Sum = 1 * CLng(rnd * [i]myNum[/i]) Label1.Caption = Sum
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