The code copy is as follows:
Functionmakegroup(teams()AsString)AsString
'Function function: Randomly group 32 teams in the teams array. (Note: the teams array subscript starts from 0)
'Variable definition of function.
'It is a good habit to show variable declarations.
DimtvarAsInteger, returnstrAsString,tmoveAsInteger,tempAsInteger
'Initialize the random number generator to achieve true randomness.
Randomize(Timer)
Fortvar=1To32'There are 32 teams in total
If(tvar-1)Mod4=0Then
'Save the group team name and group name into the returnstr variable.
returnstr=returnstr&vbCrLf&Chr(Asc("A")+(tvar/4))&"Group:"
EndIf
tmove=Int(Rnd*(33-tvar))
returnstr=returnstr&teams(tmove)&"."
Fortemp=tmoveTo30
'Move the part of the array forward to avoid the existence of teams with the same name in the group.
teams(temp)=teams(temp+1)
Nexttemp
Nexttvar
'The return value is the result after grouping.
makegroup=returnstr
EndFunction