Random Number Generator - 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) +----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9) +----- Thread: Random Number Generator (/showthread.php?tid=692) |
Random Number Generator - manishshrestha60 - 10-28-2012 I need help with random number generator and the number has to about 15 digit for example like this 123456789012345. Any help will be appreciated Re: Random Number Generator - Cartman - 10-29-2012 Hi there i have a PDF that shows you how to make a LuckySeven game that uses random numbers - <!-- m --><a class="postlink" href="http://www.mediafire.com/view/?a4y5dv9ca2ey95e">http://www.mediafire.com/view/?a4y5dv9ca2ey95e</a><!-- m --> Here is my conversion of that to 15 numbers <!-- s --><img src="{SMILIES_PATH}/icon_e_wink.gif" alt="" title="Wink" /><!-- s --> Re: Random Number Generator - manishshrestha60 - 10-29-2012 Cartman Wrote:Hi there i have a PDF that shows you how to make a LuckySeven game that uses random numbers - <!-- m --><a class="postlink" href="http://www.mediafire.com/view/?a4y5dv9ca2ey95e">http://www.mediafire.com/view/?a4y5dv9ca2ey95e</a><!-- m -->It would help if you give me the page number or a sample code Re: Random Number Generator - Cartman - 10-29-2012 manishshrestha60 Wrote:It would help if you give me the page number or a sample code Chapter 2 --> Page 37 <!-- s:oops: --><img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarrassed" /><!-- s:oops: --> Re: Random Number Generator - brandonio21 - 10-30-2012 Well, here's a quick code snippet that I crafted especially for you! Since an integer can't hold something that is 15 characters long, we need to individually generate 15 random integers and insert them into a String. Like so, [code2=vbnet]Dim randomNumberLength As Integer = 15 Dim randomNumberString As String = "" For i As Integer = 1 To randomNumberLength Step 1 Randomize() 'Randomize the numberset randomNumberString += CInt((Rnd() * 10)).ToString 'Generate a number from 0-9 and tack it onto String. Next[/code2] Hopefully this helps solve your problem. If you have any questions about this code, feel free to ask! The variable randomNumberString is now your random number of randomNumberLength characters long. |