atesh Posted September 23, 2003 Posted September 23, 2003 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). Quote To err is human, to really foul things up requires a computer.
*Experts* Volte Posted September 23, 2003 *Experts* Posted September 23, 2003 Change the number to 51. And also, it would be the second number minus 1. 1 minus the second number would be -49. :p Quote
wyrd Posted September 23, 2003 Posted September 23, 2003 It won't go up to 50 because it's basically saying, give me a random number from 1 up to 50. If you returned a double value on random, you'd get something like 1 to 49.99999999. Since you're using integer values, it's 1 to 49. Quote Gamer extraordinaire. Programmer wannabe.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.