i'm trying to make this method like, if you haven't pressed the correct value a message box will show and when you press the messagebox it will return and you have to try to put the rigth values in again and so on. And if the field is null or empty is has to give =0.. If i press ex. e2 it has to pup up with the message box??
have tried this one without the else if.. and the messagebox vil not disappear? please help
public int playerOneDart1Value;
public int calculateDart1()
{
if (player == "t1" || player == "T1" || player == "3")
{
playerOneDart1Value = 3;
}
else if (player == null) or empty??
{
playerOneDart1Value = 0;
}
else
{
MessageBox.Show("not valid input");
return calculateDart1();
}
return playerOneDart1Value;
}
You're calling return calculateDart1();
straight after showing the message box, so the user never has a chance to alter the input, before the check being made again, and showing the message box.