Question: Trying to get a counter to add the number of guesses

tried to increase the try count but unsuccessful

```
triesInteger = 0;

            if (guessInteger < numberRandom.Next(0, 10))
            {

                answerLabel.Text = "You are too low";
                numTriesLabel.Text = "" + triesInteger;
                triesInteger ++;

            }
            if (guessInteger > numberRandom.Next(0, 10))
            {

                answerLabel.Text = "You are too high";
                numTriesLabel.Text = "" + triesInteger;
                triesInteger ++;

            }
            if (guessInteger == numberRandom.Next(0, 10))
            {

                answerLabel.Text = "Correct, Way to go!";
                numTriesLabel.Text = "" + triesInteger;
                triesInteger ++;

```

when the user tries a guess the numTriesLabel should calculate the number of tries it took to get the correct random number.

Answer: 
If you to check in how many tries the user to guess the random number, then you need to fix the Random number and tries globally or outside the block when you start the game.
Example:

```
    int triesInteger = 0;
    int randomnum = new Random().Next(0, 10);
    private void button3_Click(object sender, EventArgs e)
    {
        int guessInteger;
        if (int.TryParse(textBoxcommanf.Text, out guessInteger))
        {
            if (guessInteger < randomnum)
            {
                triesInteger++;
                answerLabel.Text = "You are too low";
                numTriesLabel.Text = "" + triesInteger;

            }
            if (guessInteger > randomnum)
            {
                triesInteger++;
                answerLabel.Text = "You are too high";
                numTriesLabel.Text = "" + triesInteger;

            }
            if (guessInteger == randomnum)
            {
                triesInteger++;
                answerLabel.Text = "Correct, Way to go!";
                numTriesLabel.Text = "" + triesInteger;

            }
        }
        else
        {
            answerLabel.Text = "Number is invalid";
        }
    }

```

It creates one random number and then user start to guess the number, each tries it count increase if guess wrong it shows hint (high or low).

If you want to start again then you need to reset the value on some button click .and start again number guessing game.

```
    private void button4_Click(object sender, EventArgs e)
    {
        triesInteger = 0;
        randomnum = new Random().Next(0, 10);
        answerLabel.Text = "";
        numTriesLabel.Text = "0";
    }

```
You generate a new random at each if condition.

```
triesInteger = 0;
int number = numberRandom.Next(0,10)
if (guessInteger < number)
        {

            answerLabel.Text = "You are too low";
            numTriesLabel.Text = "" + triesInteger;
            triesInteger ++;

        }
        if (guessInteger > number)
        {

            answerLabel.Text = "You are too high";
            numTriesLabel.Text = "" + triesInteger;
            triesInteger ++;

        }
        if (guessInteger == number)
        {

            answerLabel.Text = "Correct, Way to go!";
            numTriesLabel.Text = "" + triesInteger;
            triesInteger ++;

```