# VBForums CodeBank > CodeBank - C# >  C#- HighScore List

## ErikJohansson

Hello There.

This is just a simple high score program that stores 5 scores in "settings" and displays them on labels. Not sure if anyone wants this..



```
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HighScores
{
    public partial class Form1 : Form
    {
        int NewScore;
        int[] Swap = new int[5];

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
            NewScore = Convert.ToInt32(textBox1.Text);

                if (NewScore > Convert.ToInt32(Score1.Text)) //If NewScore Is Higher Than #1
            {
                Swap[1] = Convert.ToInt32(Score1.Text);      //Swap[1] = Old Score1.Text
                Score1.Text = Convert.ToString(NewScore);    //Score1.Text = NewScore
                    Swap[2] = Convert.ToInt32(Score2.Text);  //Swap[2] Old Score2.Text
                    Score2.Text = Convert.ToString(Swap[1]); //Score2.Text = Prev Score1.Text
                    Swap[3] = Convert.ToInt32(Score3.Text);  //Swap[3] = Old Score3.Text
                    Score3.Text = Convert.ToString(Swap[2]); //score3.Text = Prev Score2.Text
                    Swap[4] = Convert.ToInt32(Score4.Text);  //Swap[4] = Old Score4.Text
                    Score4.Text = Convert.ToString(Swap[3]); //Score4.Text = Prev Score3.Text
                    Score5.Text = Convert.ToString(Swap[4]); //Score5.Text = Prev Score4.Text
            }
            else

                    if (NewScore > Convert.ToInt32(Score2.Text)) //If NewScore Is Higher Than #2
                {
                    Swap[1] = Convert.ToInt32(Score2.Text);   //Swap[1] = Old Score2.Text
                    Score2.Text = Convert.ToString(NewScore); //Score2.Text = NewScore
                    Swap[2] = Convert.ToInt32(Score3.Text);   //Swap[2] = Old Score3.Text
                    Score3.Text = Convert.ToString(Swap[1]);  //score3.Text = Old Score2.Text
                    Swap[3] = Convert.ToInt32(Score4.Text);  //Swap[3] = Old Score4.Text
                    Score4.Text = Convert.ToString(Swap[2]);  //Score4.Text = Old Score3.Text
                    Score5.Text = Convert.ToString(Swap[3]);  //Score5.Text = Old Score4.Text
                }
                else
                        if (NewScore > Convert.ToInt32(Score3.Text)) //If NewScore Is Higher Than #3
                    {
                        Swap[1] = Convert.ToInt32(Score3.Text);   //Swap[1] = Old Score3.Text
                        Score3.Text = Convert.ToString(NewScore); //Score3.Text = NewScore
                        Swap[2] = Convert.ToInt32(Score4.Text);   //Swap[2] = Old Score4.Text
                        Score4.Text = Convert.ToString(Swap[1]);  //Score4.Text = Old Score3.Text
                        Score5.Text = Convert.ToString(Swap[2]);  //Score5.Text = Old Score4.Text
                    }
                    else
                            if (NewScore > Convert.ToInt32(Score4.Text)) //If NewScore Is Higher Than #4
                        {
                            Swap[1] = Convert.ToInt32(Score4.Text);   //Swap[1] = Old Score4.Text
                            Score4.Text = Convert.ToString(NewScore); //Score4.Text = NewScore
                            Score5.Text = Convert.ToString(Swap[1]);  //Score5.Text = Prev Score4.Text
                        }
                        else
                                if (NewScore > Convert.ToInt32(Score5.Text)) //If NewScore Is Higher Than #5
                            {
                                Swap[1] = Convert.ToInt32(Score5.Text);
                                Score5.Text = Convert.ToString(NewScore); //Score5.Text = NewScore
                            }

                //Saves The HighScores
                Properties.Settings.Default.Score1 = Convert.ToInt32(Score1.Text);
                Properties.Settings.Default.Score2 = Convert.ToInt32(Score2.Text);
                Properties.Settings.Default.Score3 = Convert.ToInt32(Score3.Text);
                Properties.Settings.Default.Score4 = Convert.ToInt32(Score4.Text);
                Properties.Settings.Default.Score5 = Convert.ToInt32(Score5.Text);

                Properties.Settings.Default.Save();
            }
                catch (Exception ex)
                    {
                    }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //Loads The HighScores
            Score1.Text = Convert.ToString(Properties.Settings.Default.Score1);
            Score2.Text = Convert.ToString(Properties.Settings.Default.Score2);
            Score3.Text = Convert.ToString(Properties.Settings.Default.Score3);
            Score4.Text = Convert.ToString(Properties.Settings.Default.Score4);
            Score5.Text = Convert.ToString(Properties.Settings.Default.Score5);
        }
    }
}
```

Project Download(No debug files):
HighScores.zip

----------

