Math Game Help
hi, i am creating a math game for a class i'm in. i am creating a math game but i am having trouble trying to figure out how to check to see if the answer that was being input in correct or not that shows up in the text box. thanks in advance for the help. i am also posting the code i have written so far.

VulpesRank #55 · 29.2K reputationPosted Mar 10, 2011, 11:02 AM EST
Guest UserRank #1,422 · 1.2K reputationPosted Mar 10, 2011, 11:06 AM EST
private void btnSubmit_Click(object sender, EventArgs e)
{
if (txtNum1.Text != "" && txtNum2.Text != "" && txtBoxAns.Text != "")
{
int correctAnswer = 0;
int userAnswer = Int32.Parse(txtBoxAns.Text);
int num1 = Int32.Parse(txtNum1.Text);
int num2 = Int32.Parse(txtNum2.Text);
if (lblSign.Text == @"+")
{
correctAnswer = num1 + num2;
}
if (correctAnswer == userAnswer)
{
MessageBox.Show(@"Correct!");
}
else
{
MessageBox.Show(@"Incorrect...");
}
}
else
{
MessageBox.Show(@"Please select an operator and enter your answer");
}
}
snoun14 reputationPosted Mar 10, 2011, 11:09 AM EST
VulpesRank #55 · 29.2K reputationPosted Mar 10, 2011, 11:18 AM EST
I've also noticed a small mistake in btnSub_Click which will prevent it from working correctly:
FroglegRank #1,020 · 1.9K reputationPosted Mar 10, 2011, 11:54 AM EST
snoun14 reputationPosted Mar 10, 2011, 12:34 PM EST
FroglegRank #1,020 · 1.9K reputationPosted Mar 10, 2011, 12:51 PM EST
int score = 0;
at the top of your class
if answer is correct add 10 to score
score= score + 10;//adds ten to score
lblScore.Text = ("Score = " + Convert.ToString(score));
snoun14 reputationPosted Mar 10, 2011, 1:09 PM EST
Guest UserRank #1,422 · 1.2K reputationPosted Mar 10, 2011, 5:41 PM EST
Suthish NairRank #92 · 22.8K reputationPosted Mar 12, 2011, 8:02 AM EST