Saturday, 31 August 2013

String Stays at Default Value In Windows Form

String Stays at Default Value In Windows Form

I've been trying to fix this for an hour now to no avail. I have a text
box that I've been using for user input, and at a point in the program, I
need to ask the player what their name is. This code is inside the KeyDown
event for the text box:
if (e.KeyCode == Keys.Enter & progress == 1 & nameready == true)
{
input = inputBox.Text;
inputBox.Clear();
playername = input
}
This should work fine. I know it's not an issue with my input system,
since other if statements just like this work fine. However, in this
single statement, input always equals "". I even added an if statement to
run a method if input != "" and it never triggers. If this the input
variable doesn't work in this statement, why does it work in any others?

No comments:

Post a Comment