Using Random Class u can generate random numbers
Random RandomClass = new Random();
We're not supposed to help with school assignments so be careful what you ask for in future...
Here is a standard function that you'll find littering the internet though
- Public Function RandomNum(ByVal Low As Integer, ByVal High As Integer) As Integer
-
Randomize()
-
Return CType(Rnd() * (High - Low), Integer) + Low
-
End Function
-
-
Dim MyRandomNum As integer = RandomNum(10, 20)
It allows you to pass a low end number and a high end number and a pseudo-random number will be generated between those two numbers. In the example I used 10 as the low end and 20 as the high end. Take note of the Randomize and Rnd functions which are the core of the method.
I've had limited success with the Random class for this purpose. It seems that the mechanism built into it for generating the random number is sensitive to time so if you need to generate a large amount of apparently random numbers this function will perform better than the Random class.