Hi, I'm creating a program that has the following features:
1. Load names (1 per line) from a text file into a list box on a button click event - DONE
2. Ability to add or delete names from this list box - DONE
3. Re-save the contents of the list box to the original text file - DONE
4. Load the contents of the list box into an array (just doing this from a click event) - DONE
5. Randomly assign each name in the array to one of two further list boxes (or they could be text boxes) - THIS IS WHY I COME UNSTUCK!
How do I do step 5?
I can create random numbers easily enough, but I want the names in the array (which are likely to be in alphabetical order from the original list box elsewhere in the form) to be distributed into other controls. Think of it like this:
1. The user has the ability to manipulate names in the array by the add/delete options in the original list box
2. Once the up-to-date list of names are in the array, the names can then be distributed into 2 teams
The following code just gives be
String[] Array repeated 5 times in one list box only:
CODE
'Variable for random number assign to each item in the array
Dim intRandomNumber As Integer
'Initiate the random number generator
Randomize()
'General random numbers
'equivalent to the maximum number of names stored in the array
intRandomNumber = (Int(UBound(Names) - LBound(Names) + 1) * Rnd() + LBound(Names))
'Assign each name in the array with a random number
For i = 0 To UBound(Names) - 1
ReDim Preserve Names(i + 1)
Names(i) = intRandomNumber
If intRandomNumber = 1 Or 3 Or 5 Or 7 Or 9 Or 11 Then
lstTeamOne.Items.Add(Names)
Else
lstTeamTwo.Items.Add(Names)
End If
Next i
Thanks,
Any help would be greatly appreciated