atesh
Freshman
I'm trying to generate 1,000 random whole numbers from 1 to 100, then put them in a listbox and show how many times each number(1 to 100) was picked randomly.
But when using the code above I get all numbers 1 to 100 as -- 0, except the following: 3-- 160, 25-- 241, 48-- 209, 58-- 148, 80-- 242.
So what the heck is going on?
Thanks alot.
Visual Basic:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim rambo As Integer
Dim x, y As Integer
Dim dist(100) As Integer
For x = 1 To 1000
rambo = New System.Random().Next(1, 100)
dist(rambo) += 1
Next
For y = 1 To 100
ListBox1.Items.Add(y & "-- " & dist(y))
Next
End Sub
But when using the code above I get all numbers 1 to 100 as -- 0, except the following: 3-- 160, 25-- 241, 48-- 209, 58-- 148, 80-- 242.
So what the heck is going on?
Thanks alot.