Hi,
I am trying to create a league table. There are eight teams. The teams and their results are added to a text file on one form. The teams and results are seperated by a comma. On the second form i have a label where I am trying to display the teams and the total of points they have earned. For example in week one team 1 will play team 2 team one will have 3 points and team 2 will have 2 points. In week 2 team 1 will play team3, team 1 will have 2 points and team 3 will have 4 points. What i am trying to achieve is the label to display all eight teams with the total amount of points next to them. So team i should have 5 points next to their name. With the following code I have managed to display the first team and their first points (not all added together) and that is all. Could anyone please help?

public partial class frmLeague : Form
    {
        public frmLeague()
        {
            InitializeComponent();
        }
int[] Scores = new int[8]{0,0,0,0,0,0,0,0};  

string[] Teams = new string[8] { "The Flying Handbag", "South Shore Labour Club", "Kirkham Liberal Club", "Rossall Tavern", "Blackpool Deaf Society", "The Dinmore Hotel", "The Gardeners Arms", "Bispham Conservative Club" };
private void btnShow_Click(object sender, EventArgs e)
        {
TextReader Reader = new StreamReader("results.txt");
string OutPut;
            
while (Reader.Peek()>8)
     {
      OutPut = Reader.ReadLine();

      string[] Split = OutPut.Split(new Char[] { ',' });

      for (int count = 0; count < 8; count++)
          { 
            if (Split[0] == Teams[count])
              {
                Scores[count] = Scores[count] + Convert.ToInt32(Split[1]);
              }
          }
        lblLeagueTable.Text = (Convert.ToString(Split[0]) + (Convert.ToString(Split[1])));    
      }

Reader.Close();
 }

I forgot to mention the text file i am using has a team name on a line followed by a comma then the teams results/point. For example:
South Shore Labour Club, 3
Dinmore Hotel, 2
The Highcross Pub, 4
etc
In total there are 8 teams. In one week they all play and the teams and their results/points are enterd into the text file. The following week all 8 teams play again and the teams and their results are entered into the text file again.
So after 2 weeks, the text file has 16 lines of text. What I wanted to do with this program was to display all 8 teams in a label with the total amount of points they have won. For example if the South Shore Labour Club played one week and won 3 points, then the following week won 2 points, I want to display the total of 5 points next to the teams name in the label. I have tried to do this with arrays, but I am struggling.
If i show the teams and points in a message box it will display all 16 lines of text. When i try to display the teams and points on the label only the first line from the text file is displayed. No matter what I try nothing seems to work. Could anyone please help?
Thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.