Generating Random Numbers in Visual Basic - Printable Version +- BP Forums (https://bpforums.info) +-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55) +--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56) +---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8) +---- Thread: Generating Random Numbers in Visual Basic (/showthread.php?tid=498) |
Generating Random Numbers in Visual Basic - Himansh - 03-25-2012 I recently watched this video <!-- m --><a class="postlink" href="http://www.youtube.com/watch?feature=player_detailpage&v=G1reHzr3DCI">http://www.youtube.com/watch?feature=pl ... 1reHzr3DCI</a><!-- m --> And the video shows this frmula for generating random number (highnumber-lownumber+1) *Rnd() + lownumber Can anybody tell me how does this formula works I.e the logic behind this formula Thanks in Advance!!! Re: Generating Random Numbers in Visual Basic - brandonio21 - 03-25-2012 Well, it has to do with the formula for finding the average value of a function, where the average value is (1 / b - a) * (a to b)(Integral(ƒ(x)). Since the Rnd() Function only generates numbers between 0 and 1, we need to multiply and add values in order to enter the range we want. |