Anyone let me know what is going on here? Think it is something to do with the scope.
double answer;
if (sender is System.Windows.Forms.Button)
{
try
{
answer = Convert.ToDouble(answerBox.Text);//if cannot convert
}
catch (Exception ex)
{
MessageBox.Show("Enter a valid number" + ex.Message(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
setPicsToVisible();//this method sets pictures to non visible
if (currentUser.numQuestionsComplete < 10)
{
checkAnswer(setValues, answer);
currentUser.numQuestionsComplete++;
determineShape();//get shape to be
}
Now when the first if statement round the try catch block is removed, no errors show to me. If i keep the if statement in, i get an error that i do not assign any value to 'answer' which is annoying because i don't see how one if statement is stopping me from doing this?