how do i generate random number in vb ?
first in the forms load event write: "randomize" then when you wish to call a random number write: "variablex = rnd()* 100" '<----will give you a random number 1 - 100 hope it helps rob
http://www.vbforums.com/showthread.php?t=281172
Alter ego
here's a handy little piece of code: VB Code: Public Function RandomNumber(Min as Double, Max as Double, Optional WholeNumber as Boolean = True) If WholeNumber = True then RandomNumber = Int(Rnd() * (Max - Min) + Min) Else RandomNumber = Rnd() * (Max - Min) + Min End If End Function
Public Function RandomNumber(Min as Double, Max as Double, Optional WholeNumber as Boolean = True) If WholeNumber = True then RandomNumber = Int(Rnd() * (Max - Min) + Min) Else RandomNumber = Rnd() * (Max - Min) + Min End If End Function
Do you wake up in the morning feeling sleepy and grumpy? Then you must be Snow White
job done, but da last code is more helpful !
Forum Rules