Question : Visual Basic .net Random class, next problem

If i have a randomClass.next within a loop, i get the same result....For each loop
Why is that?

1:
2:
3:
4:
5:
6:
7:
For i = 0 To 10
            Dim RandomClass As New Random()
            Dim r1 As Integer
            r1 = RandomClass.Next(1, 90)
            System.Diagnostics.Debug.Print(r1)
        Next


the code above will give me this
11
11
43
43
43
43
43
43
43
43
43

Why is that?

Answer : Visual Basic .net Random class, next problem

take the dim statement outside of the loop
1:
2:
3:
4:
5:
6:
7:
            Dim RandomClass As New Random()

For i = 0 To 10
            Dim r1 As Integer
            r1 = RandomClass.Next(1, 90)
            System.Diagnostics.Debug.Print(r1)
        Next
Random Solutions  
 
programming4us programming4us