473,748 Members | 9,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB House Assignment

10 New Member
Hi everyone,
My most important college assignment to date seems pretty basic on the outside
but I'm sure this will interest a few of you.

If you see this document:
http://stair.stcoll.ac .uk/jowen/btecsd/pconc/docs/IVA1.pdf and take a brief look
to see what it's all about, (a fixtures and points system for a school) take a
look on page 3, to see the list of students with their names, house and class.

Then look on page 2 to see the rules set down to create these fixtures.

I have learnt that it is pretty impossible to create these fixtures using code
and would like to know your views.

There should be 18 matches per game (there are 4 games).

So far, I have managed to get 18 matches for 2 games, 17 for one game and 16 for
the last. This is because as you get to the end of the fixture assignment, you
run out of players to play each other.

I'm sure there is some mathematical way of working it out, and I am probably
going to leave my results how they are now as it is as good as it needs to be
for my assigment, but it interests me a lot and wondered if anyone else has an
easy way of implementing this program.

I will post my code here for you too, to take a quick look. Sorry if it is
crap/hard to read/whatever, just give me your views. If I could find out how to
code it properly for the hand in date (next thursday lol) then I suppose thats a
cool bonus.

Have fun!
Gisterogue

NOTE: I apologise.. we MUST use VB 6 :(

CODE: The Create fixtures form
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdMore_Click() 
  2.  
  3. 'show results 
  4. Me.Height = 8220 
  5. Me.Top = Screen.Height / 2 - (Me.Height / 2) 
  6. End Sub 
  7.  
  8. Private Sub Form_Load() 
  9.  
  10. Dim x As Integer 
  11. Dim y As Integer 
  12. Dim z As Integer 
  13. Dim Method As Boolean 
  14. Dim intArrayIndex As Integer 
  15.  
  16. Method = True 
  17.  
  18. 'loop for every game 
  19. For x = 1 To 4 
  20.  
  21.     'loop through every pupil 
  22.  
  23.     For y = UBound(Competitor) To LBound(Competitor) Step -1 
  24.         'first check if their match is set 
  25.         If Competitor(y).Games(x).Against = "" Then 
  26.  
  27.             'next find an opponent, to do this just check 
  28.             '1) if the opponent already has a game or not 
  29.             '2) if the opponent is in same class or house 
  30.             '3) if opponent has already played this player or not 
  31.  
  32. If Method = False Then 
  33. '''''''''''''''''''''''''''''''''''' 
  34.             For z = UBound(Competitor) To LBound(Competitor) Step -1 
  35.  
  36.             If Not playedEachother(y, z) Then 
  37.                 If Competitor(z).Class <> Competitor(y).Class Then 
  38.                     If Competitor(z).House <> Competitor(y).House And
  39. Competitor(z).Class <> Competitor(y).Class Then 
  40.                             If Competitor(z).Games(x).Against = "" Then 
  41.  
  42.                                 'set player 
  43.                                 Competitor(y).Games(x).Against =
  44. Competitor(z).Name 
  45.                                 'MsgBox Competitor(y).Games(x).Against 
  46.                                 'set other player too 
  47.                                 Competitor(z).Games(x).Against =
  48. Competitor(y).Name 
  49.                                 'MsgBox Competitor(z).Games(x).Against 
  50.  
  51.                                 txtMatches.Text = txtMatches.Text &
  52. Competitor(y).Games(x).Type & ": " & Competitor(y).Name & " (House: " &
  53. Competitor(y).House & " Class: " & Competitor(y).Class & ") vs " &
  54. Competitor(z).Name & " (House: " & Competitor(z).House & " Class: " &
  55. Competitor(z).Class & ")" & vbCrLf 
  56.  
  57.                                 'escape from loop 
  58.                                 z = LBound(Competitor) - 1 
  59.  
  60.                             End If 
  61.                     End If 
  62.                 End If 
  63.             End If 
  64.  
  65.             Next 
  66.  
  67.             Method = Not Method 
  68. ''''''''''''''''''''''''''''''''''' 
  69. Else 
  70.             For z = LBound(Competitor) To UBound(Competitor) 
  71.  
  72.             If Not playedEachother(y, z) Then 
  73.                 If Competitor(z).Class <> Competitor(y).Class Then 
  74.                     If Competitor(z).House <> Competitor(y).House And
  75. Competitor(z).Class <> Competitor(y).Class Then 
  76.                             If Competitor(z).Games(x).Against = "" Then 
  77.  
  78.                                 'set player 
  79.                                 Competitor(y).Games(x).Against =
  80. Competitor(z).Name 
  81.                                 'MsgBox Competitor(y).Games(x).Against 
  82.                                 'set other player too 
  83.                                 Competitor(z).Games(x).Against =
  84. Competitor(y).Name 
  85.                                 'MsgBox Competitor(z).Games(x).Against 
  86.  
  87.                                 txtMatches.Text = txtMatches.Text &
  88. Competitor(y).Games(x).Type & ": " & Competitor(y).Name & " (House: " &
  89. Competitor(y).House & " Class: " & Competitor(y).Class & ") vs " &
  90. Competitor(z).Name & " (House: " & Competitor(z).House & " Class: " &
  91. Competitor(z).Class & ")" & vbCrLf 
  92.  
  93.                                 'escape from loop 
  94.                                 z = UBound(Competitor) + 1 
  95.  
  96.                             End If 
  97.                     End If 
  98.                 End If 
  99.             End If 
  100.  
  101.             Next 
  102.             Method = Not Method 
  103. End If 
  104. '''''''''''''''''''''''''''''''''' 
  105.  
  106.         End If 
  107.  
  108.     Next 
  109.  
  110. Next 
  111.  
  112. MsgBox "Your fixtures have been generated.", vbOKOnly, "Fixtures Generated" 
  113.  
  114. ''''when fixtures are finished!!''' 
  115. 'show button 
  116. Me.Height = 1725 
  117.  
  118. End Sub 
  119.  
  120. Private Function playedEachother(Player1Index As Integer, Player2Index As
  121. Integer) As Boolean 
  122.  
  123. Dim x As Integer 
  124.  
  125. For x = 1 To 4 
  126.  
  127.     If Competitor(Player1Index).Games(x).Against = Competitor(Player2Index).Name
  128. Then 
  129.         If Competitor(Player1Index).Games(x).Against <> "" Or
  130. Competitor(Player2Index).Games(x).Against <> "" Then 
  131.             playedEachother = True 
  132.             Exit Function 
  133.         End If 
  134.     End If 
  135.  
  136. Next 
  137.  
  138. playedEachother = False 
  139.  
  140. End Function 
  141.  
code: the module I also have

Expand|Select|Wrap|Line Numbers
  1. 'This module holds all the data needed 
  2. 'for the salchester primary school to run 
  3.  
  4. Option Explicit 
  5.  
  6. 'hold users access level 
  7. Public ACCESS_LEVEL As Integer 
  8. 'hold users current program section 
  9. Public CURRENT_SECTION As Integer 
  10. 'hold correct username 
  11. Public CORRECT_USERNAME As String 
  12. 'hold correct password 
  13. Public CORRECT_PASSWORD As String 
  14. 'hold games 
  15. Public Type Game 
  16.     Type As String 
  17.     Played As Boolean 
  18.     Won As Boolean 
  19.     Against As String 
  20. End Type 
  21. 'hold pupils 
  22. Public Type Player 
  23.     Name As String 
  24.     Class As Integer 
  25.     House As String 
  26.     Games(1 To 4) As Game 
  27.     Available As Boolean 
  28. End Type 
  29. Public Competitor(1 To 36) As Player 
  30.  
  31. Public Sub Initialize() 
  32.  
  33.     'set default username and password 
  34.     CORRECT_USERNAME = "user" 
  35.     CORRECT_PASSWORD = "pass" 
  36.  
  37.     'set player details 
  38.     Call setPlayerDefaults 
  39.  
  40. End Sub 
  41.  
  42. Private Sub setPlayerDefaults() 
  43.  
  44. 'first set default games 
  45.  
  46. Dim x As Integer 
  47.  
  48. For x = LBound(Competitor) To UBound(Competitor) 
  49.         Competitor(x).Games(1).Type = "Snap" 
  50.         Competitor(x).Games(2).Type = "Cribbage" 
  51.         Competitor(x).Games(3).Type = "Spillikins" 
  52.         Competitor(x).Games(4).Type = "Junior Scrabble" 
  53. Next 
  54.  
  55. 'next set all the names and other data of competitors 
  56. With Competitor(1) 
  57.     .Name = "Albert" 
  58.     .Class = 1 
  59.     .House = "Yellow" 
  60. End With 
  61.  
  62. With Competitor(2) 
  63.     .Name = "Arnold" 
  64.     .Class = 1 
  65.     .House = "Green" 
  66. End With 
  67.  
  68. With Competitor(3) 
  69.     .Name = "Aswan" 
  70.     .Class = 1 
  71.     .House = "Yellow" 
  72. End With 
  73.  
  74. With Competitor(4) 
  75.     .Name = "Bertha" 
  76.     .Class = 1 
  77.     .House = "Green" 
  78. End With 
  79.  
  80. With Competitor(5) 
  81.     .Name = "Betty" 
  82.     .Class = 1 
  83.     .House = "Yellow" 
  84. End With 
  85.  
  86. With Competitor(6) 
  87.     .Name = "Bella" 
  88.     .Class = 1 
  89.     .House = "Green" 
  90. End With 
  91.  
  92. With Competitor(7) 
  93.     .Name = "Charles" 
  94.     .Class = 2 
  95.     .House = "Green" 
  96. End With 
  97.  
  98. With Competitor(8) 
  99.     .Name = "Colin" 
  100.     .Class = 2 
  101.     .House = "Yellow" 
  102. End With 
  103.  
  104. With Competitor(9) 
  105.     .Name = "Denise" 
  106.     .Class = 2 
  107.     .House = "Green" 
  108. End With 
  109.  
  110. With Competitor(10) 
  111.     .Name = "Debra" 
  112.     .Class = 2 
  113.     .House = "Yellow" 
  114. End With 
  115.  
  116. With Competitor(11) 
  117.     .Name = "Edward" 
  118.     .Class = 3 
  119.     .House = "Green" 
  120. End With 
  121.  
  122. With Competitor(12) 
  123.     .Name = "Elias" 
  124.     .Class = 3 
  125.     .House = "Yellow" 
  126. End With 
  127.  
  128. With Competitor(13) 
  129.     .Name = "Earl" 
  130.     .Class = 3 
  131.     .House = "Green" 
  132. End With 
  133.  
  134. With Competitor(14) 
  135.     .Name = "Felicity" 
  136.     .Class = 3 
  137.     .House = "Yellow" 
  138. End With 
  139.  
  140. With Competitor(15) 
  141.     .Name = "Freda" 
  142.     .Class = 3 
  143.     .House = "Green" 
  144. End With 
  145.  
  146. With Competitor(16) 
  147.     .Name = "Fiona" 
  148.     .Class = 3 
  149.     .House = "Yellow" 
  150. End With 
  151.  
  152. With Competitor(17) 
  153.     .Name = "George" 
  154.     .Class = 4 
  155.     .House = "Green" 
  156. End With 
  157.  
  158. With Competitor(18) 
  159.     .Name = "Gilbert" 
  160.     .Class = 4 
  161.     .House = "Yellow" 
  162. End With 
  163.  
  164. With Competitor(19) 
  165.     .Name = "Gerry" 
  166.     .Class = 4 
  167.     .House = "Green" 
  168. End With 
  169.  
  170. With Competitor(20) 
  171.     .Name = "Gwyn" 
  172.     .Class = 4 
  173.     .House = "Yellow" 
  174. End With 
  175.  
  176. With Competitor(21) 
  177.     .Name = "Harriet" 
  178.     .Class = 4 
  179.     .House = "Green" 
  180. End With 
  181.  
  182. With Competitor(22) 
  183.     .Name = "Hebe" 
  184.     .Class = 4 
  185.     .House = "Yellow" 
  186. End With 
  187.  
  188. With Competitor(23) 
  189.     .Name = "Helen" 
  190.     .Class = 4 
  191.     .House = "Green" 
  192. End With 
  193.  
  194. With Competitor(24) 
  195.     .Name = "Hilary" 
  196.     .Class = 4 
  197.     .House = "Yellow" 
  198. End With 
  199.  
  200. With Competitor(25) 
  201.     .Name = "Ian" 
  202.     .Class = 5 
  203.     .House = "Green" 
  204. End With 
  205.  
  206. With Competitor(26) 
  207.     .Name = "Idris" 
  208.     .Class = 5 
  209.     .House = "Yellow" 
  210. End With 
  211.  
  212. With Competitor(27) 
  213.     .Name = "Isaac" 
  214.     .Class = 5 
  215.     .House = "Green" 
  216. End With 
  217.  
  218. With Competitor(28) 
  219.     .Name = "Jane" 
  220.     .Class = 5 
  221.     .House = "Yellow" 
  222. End With 
  223.  
  224. With Competitor(29) 
  225.     .Name = "Jenny" 
  226.     .Class = 5 
  227.     .House = "Green" 
  228. End With 
  229.  
  230. With Competitor(30) 
  231.     .Name = "Jasmine" 
  232.     .Class = 5 
  233.     .House = "Yellow" 
  234. End With 
  235. With Competitor(31) 
  236.     .Name = "Keith" 
  237.     .Class = 6 
  238.     .House = "Green" 
  239. End With 
  240.  
  241. With Competitor(32) 
  242.     .Name = "Kenny" 
  243.     .Class = 6 
  244.     .House = "Yellow" 
  245. End With 
  246.  
  247. With Competitor(33) 
  248.     .Name = "Kevin" 
  249.     .Class = 6 
  250.     .House = "Green" 
  251. End With 
  252.  
  253. With Competitor(34) 
  254.     .Name = "Laura" 
  255.     .Class = 6 
  256.     .House = "Yellow" 
  257. End With 
  258.  
  259. With Competitor(35) 
  260.     .Name = "Leila" 
  261.     .Class = 6 
  262.     .House = "Green" 
  263. End With 
  264.  
  265. With Competitor(36) 
  266.     .Name = "Linda" 
  267.     .Class = 6 
  268.     .House = "Yellow" 
  269. End With 
  270.  
  271. End Sub
Thanks everyone!!
Nov 14 '07 #1
1 1339
debasisdas
8,127 Recognized Expert Expert
We are not here to do your home work.

Please follow the posting guidelines in every new post/reply.
Nov 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

23
3233
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since there are no assignment expressions in Python, I have to use a temp var. That's a little more messy, but bearable:
10
8741
by: mwdsmith | last post by:
Hi, I'm new to python, and I'm not sure if this is the place to post this kind of question; so feel free to tell me if I should take this elsewhere. So, to start me off on python, I decided to put together a little script to test the probabilities of rolling certain combinations of dice. Below is my code for checking for a full house (when rolling with 5 dice). A roll is a list, eg (this example is not a full house)
10
3317
by: Andrew Koenig | last post by:
It has been pointed out to me that various C++ books disagree about the relative precedence of ?: and the assignment operators. In order to satisfy myself about the matter once and for all, I looked at the grammar in the C++ standard. The relative fragments are as follows: conditional-expression: logical-or-expression logical-or-expression ? expression : assignment-expression
5
4833
by: CoolPint | last post by:
It seems to me that I cannot assign objects of a class which has a constant data member since the data member cannot be changed once the constructor calls are completed. Is this the way it is meant to be? Am I not suppose not to have any constant data member if I am going to have the assignment operator working for the class? Or am I missing something here and there is something I need to learn about? Clear, easy to understand...
0
1174
by: louis | last post by:
For those in the DFW area, there's an IT open house at Perot Systems. (In my group, we're looking to hire one senior sql server DBA. Go to the perot systems web site to apply). ------------------------------------------------------------ You're Invited to Perot Systems IT Career Open House - July 14, 2005 To meet our growth needs, Perot Systems is hosting an IT Career Open House at the company's Plano campus. If you have the skills...
35
2450
by: nagy | last post by:
I do the following. First create lists x,y,z. Then add an element to x using the augumented assignment operator. This causes all the other lists to be changed also. But if I use the assignment x=x+ instead of using the augumented assignment, the y and z lists do not change. Why is that? This does not happen when I work with integer data type for example, as shown below. Thanks for your help
20
2134
by: TimeHorse | last post by:
I would like to gauge interest in the following proposal: Problem: Assignment statements cannot be used as expressions. Performing a list of mutually exclusive checks that require data processing can cause excessive tabification. For example, consider the following python snipet...
6
3741
by: Arben | last post by:
Can anyone halp me to write the Java code for thid exercise? -------------------------------------------------------------------------------------------------------------- Exercise: Use the class from the previous exercise to build a game called \draw the house." The objective is to throw a die repeatedly, and based on the outcome, draw parts of a house. A throw of 6 lets one draw the building, a square; a throw of 5 lets one draw the...
2
1341
by: Stef Mientki | last post by:
hello, In the code below, I can build a large street like this: large_street = house * 25 but not a small street. like this: small_street = 5 * house Why is this different ? And more interesting, how do I get the right results ?
0
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.