//this is the method
private bool isInt(string strInput)
{
int dataParse = 0;
if(int.TryParse(strInput, out dataParse) == true)
{
return true;
}
else
{
return false;
}
}
//This is the code
if (txtFirstNumber.TextLength > 0 && txtSecondNumber.TextLength > 0)
{
int exp = 0;
//Check that the second number is an integer
try
{
if (isInt(txtSecondNumber.Text) == true)
{
exp = Convert.ToInt32(txtSecondNumber.Text);
}
}
//If it is not an integer, give an error
catch (FormatException)
{
MessageBox.Show("Second number must be an integert value.");
txtSecondNumber.Focus();
}