Unnamed
public text v1 · immutableint exp = Convert.ToInt16(txtSecondNumber.Text);
//Check the numbers
if (txtFirstNumber.TextLength > 0 && txtSecondNumber.TextLength >0)
{
//Check that the second number is an integer
try
{
exp = (int.Parse(txtSecondNumber.Text));
}
//If it is not an integer, give an error
catch(FormatException)
{
MessageBox.Show(" Second number must be a integert value.", "Entry Error");
txtSecondNumber.Focus();
}
}
//If There is data, do the math
{
decimal result = 1;
for (int i = 0; i < exp; i++)
result*=exp;
txtResult.Text = result.ToString("c");
}