I'm creating a simple application just for the benefit on learning and I need a way to bring up and error message if the user enters in a string instead of an integer on this variable:

Code:
int guess = Convert.ToInt32(txtGuess.Text);
I have a try statement just after this but the problem is of course and error occurs before that. However if i put this variable inside the try statement nothing else can access it.

Code:
            try
            {
                if (guess > 1000 || guess < 0)
                {
                    throw new ArgumentException();
                }
                else if (guess.GetType().Name != "Int32")
                {
                    throw new FormatException();
                }
            }
How can i prevent the user from entering in anything other than an integer? Thanks for any help