Reputation: 11
I am new to MS Visual Basic 2008. In fact, I am currently enrolled in the class. My final project for the class will generate random numbers within a range of numbers. For example, if I give the user five text windows to choose whether to input a number OR generate a random number, I will have a button called RANDOMIZE. Unfortunately, I do not know the line(s) of code for the random function.
Thank you for the assistance.
Upvotes: 1
Views: 4925
Reputation: 100567
Try this method to generate a random number with a given min and max range:
Private Function GenerateRandomNumber(min As Integer, max As Integer) As Integer
Dim random As New Random()
Return random.Next(min, max)
End Function
Call it like this:
Dim i As Integer = GenerateRandomNumber(0,Int32.MaxValue);
Upvotes: 3