I have been working on a school project that is to randomly select 14 names from a class (of 33) and place them in a list box.
My thinking behind it was to create an array that would randomly select 14 numbers from 1 to 33 and then use a Select Case statement to convert the numbers to names . . . however I am failing. I have tried putting the case statement in both the list box and in other places but cannot seem to fathom where it is I am going wrong.
Can anyone offer any advice?
Public Class Form1
Dim iNumber As Integer
Dim arrNumber(0 To 13) As Integer
Public Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ProgressBar1.Maximum = 28
End Sub
Private Sub bRandom_Click(sender As System.Object, e As System.EventArgs) Handles bRandom.Click
Dim x, y, z As Integer
For x = 0 To 13
stage1:
Randomize()
iNumber = Int((33 * Rnd()) + 1)
For y = 0 To 13
If iNumber = arrNumber(y) Then
GoTo stage1
ElseIf arrNumber(13) > 0 Then
GoTo stage2
End If
Next y
arrNumber(x) = iNumber.ToString
ProgressBar1.Increment(1)
Next x
stage2:
For z = 0 To 13
LBOSCEStations.Items.Add(arrNumber(z))
Select Case iNumber
Case 1
arrNumber(z) = "Harry"
Case 2
arrNumber(z) = "Sally"
Case 3
arrNumber(z) = "Billy
End Select
Next
End Sub
End Class