Random Nums Problem

atesh

Active member
Joined
Aug 2, 2003
Messages
41
Location
Washington State, USA
Code:
Dim GetRan As New Random
GetRan.Next(1, 50)

Why is it that this will never return the number 50? I thought the first number (in this case 1) is supposed to be the lowest possible number to return, and the second number (in this case 50) is supposed to be the highest possible number to return. But apparently, the highest number it can return is 1 - the second number (in this case 49).
 
Change the number to 51.

And also, it would be the second number minus 1. 1 minus the second number would be -49. :p
 
It wont go up to 50 because its basically saying, give me a random number from 1 up to 50. If you returned a double value on random, youd get something like 1 to 49.99999999. Since youre using integer values, its 1 to 49.
 
Back
Top