Posts: 74
Threads: 19
Joined: Aug 2012
Reputation:
0
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
Posts: 1,006
Threads: 111
Joined: Jul 2010
Reputation:
1
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.