This question is more directed to CajunCenturion since he helped me with the original code; but any input, idea, advice from others is more than welcome.
Well Mr. Cajun if you remember you gave me some very helpful code to create a Round Robin Scheduler for this Softball league I am making a program for. You also checked my code for the randomization of the teams so they could be put in a random order. Well at any rate the randomizer works good and the scheduler works good and together they work great. One thing that I want to do is be able to match the numbers that I get from the Scheduler back with the numbers I get from the Randomizer and put them in a table together. Can you point me in the right direction????
thank for any help in advanced.
If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmmv
Well Mr. Cajun if you remember you gave me some very helpful code to create a Round Robin Scheduler for this Softball league I am making a program for. You also checked my code for the randomization of the teams so they could be put in a random order. Well at any rate the randomizer works good and the scheduler works good and together they work great. One thing that I want to do is be able to match the numbers that I get from the Scheduler back with the numbers I get from the Randomizer and put them in a table together. Can you point me in the right direction????
Code:
Public Function RoundRobin(NumTeam As Integer, Rotations As Integer) As Collection
Dim Schedule As New Collection
Dim IsEven As Boolean
Dim LeftTeam() As Integer
Dim RghtTeam() As Integer
Dim HalfTeam As Integer
Dim LastTeam As Integer
Dim TeamNum As Integer
'Dim Rotations As Integer
Dim Idx1 As Integer
Dim Idx2 As Integer
Dim GameID As String
Dim SaveTeam As Integer
IsEven = ((NumTeam / 2) = (NumTeam \ 2))
HalfTeam = IIf((IsEven), Int(NumTeam / 2), (Int(NumTeam / 2) + 1))
LastTeam = HalfTeam - 1
ReDim LeftTeam(LastTeam)
ReDim RghtTeam(LastTeam)
TeamNum = IIf((IsEven), 1, 0)
For Idx1 = 0 To LastTeam
LeftTeam(Idx1) = TeamNum
RghtTeam(Idx1) = TeamNum + HalfTeam
TeamNum = TeamNum + 1
Next Idx1
Set Schedule = New Collection
'Rotations = IIf((IsEven), (NumTeam - 1), (NumTeam))
For Idx1 = 1 To Rotations
'Schedule.Add "ROUND: " & Trim(Idx1)
'Schedule.Add "-------------"
For Idx2 = 0 To LastTeam
If (LeftTeam(Idx2) > 0) Then
GameID = Trim(RghtTeam(Idx2)) & " vs " & Trim(LeftTeam(Idx2))
Else
GameID = Trim(RghtTeam(Idx2)) & " Idle"
End If
Schedule.Add GameID
Next Idx2
SaveTeam = LeftTeam(1)
For Idx2 = 1 To LastTeam - 1
LeftTeam(Idx2) = LeftTeam(Idx2 + 1)
Next Idx2
LeftTeam(LastTeam) = RghtTeam(LastTeam)
For Idx2 = LastTeam To 1 Step -1
RghtTeam(Idx2) = RghtTeam(Idx2 - 1)
Next Idx2
RghtTeam(0) = SaveTeam
Next Idx1
Set RoundRobin = Schedule
'MsgBox Schedule, , "Sample Schedule"
End Function
Public Function RandomizeThenSplit()
Dim Idx As Integer
Dim Idx2 As Integer
Dim TeamCollect1 As New Collection
Dim TeamCollect2 As New Collection
Dim ThisTeam As Class2
Dim NameList As String
Dim NameList2 As String
Dim myclasses1 As New Collection
Dim myclasses2 As New Collection
Dim MyObject As Variant
Dim IsEven As Boolean
Dim HalfTeam As Integer
Dim NumTeam As Integer
For Idx = 0 To lstTeams.ListCount
If (Len(lstTeams.ItemData(Idx) > "")) Then
Set ThisTeam = New Class2
ThisTeam.InstanceName = lstTeams.ItemData(Idx)
TeamCollect1.Add Item:=ThisTeam
Set ThisTeam = Nothing
End If
Next Idx
NumTeam = lstTeams.ListCount
IsEven = ((NumTeam / 2) = (NumTeam \ 2))
HalfTeam = IIf((IsEven), Int(NumTeam / 2), (Int(NumTeam / 2) + 1))
Randomize
Do While TeamCollect1.Count > 0
For Idx2 = 1 To HalfTeam
Idx = Int((Rnd * TeamCollect1.Count) + 1)
myclasses1.Add TeamCollect1.Item(Idx)
TeamCollect1.Remove (Idx)
Next Idx2
For Idx2 = 1 To (NumTeam - HalfTeam)
Idx = Int((Rnd * TeamCollect1.Count) + 1)
myclasses2.Add TeamCollect1.Item(Idx)
TeamCollect1.Remove (Idx)
Next Idx2
Loop
Idx = 0
For Each MyObject In myclasses1 ' Create list of names.
Idx = Idx + 1
NameList = NameList & Idx & ") " & MyObject.InstanceName & Chr(13)
Next MyObject
Idx = 0
For Each MyObject In myclasses2 ' Create list of names.
Idx = Idx + 1
NameList2 = NameList2 & Idx & ") " & MyObject.InstanceName & Chr(13)
Next MyObject
MsgBox NameList, , "Team Names In League A Collection"
MsgBox NameList2, , "Team Names In League B Collection"
LeagueA = myclasses1.Count
LeagueB = myclasses2.Count
Set myclasses1 = Nothing
Set myclasses2 = Nothing
End Function
thank for any help in advanced.
If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmmv