Code-application techniques for implementing random grouping programs in ASP

Source: Internet
Author: User
Copy Code code as follows:


Function Makegroup (Teams () as String) as String
' function function: Randomly grouping 32 teams in a teams array. (Note: Teams array subscript starting from 0)
' The variable definition of the function.
' It's a good habit to show variable declarations.
Dim Tvar As Integer, returnstr as String, tmove as Integer, temp as Integer
' Initialize the random number generator to achieve real randomness.
Randomize (Timer)
For tvar = 1 to 32 ' a total of 32 teams
If (tvar-1) Mod 4 = 0 Then
' Keep the team name and group name in the RETURNSTR variable.
Returnstr = returnstr & vbCrLf & Chr (ASC ("A") + (Tvar \ 4)) & "group:"
End If
Tmove = Int (Rnd * (33-tvar))
RETURNSTR = returnstr & Teams (Tmove) & "."
For temp = Tmove to 30
' Move the portion of the array forward to avoid a team with the same name in the group.
Teams (temp) = Teams (temp + 1)
Next Temp
Next Tvar
' The return value is the result of grouping.
Makegroup = Returnstr
End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.