I have a form the checks that several textBox’s aren’t null. If either of them are, it is supposed to show a message box, reset the text boxes and let the user try again. I believe i’m checking the textbox wrong. How can I do this? Thanks.
public void ShowPaths()
{
if (textBox1.Text == null | textBox2.Text == null)
{
MessageBox.Show("Please enter a Project Name and Number");
}
else
{
sm.projNumber = textBox1.Text;
sm.projName = textBox2.Text;
textBox3.Text = sm.Root("s");
textBox4.Text = sm.Root("t");
}
textBox1.ResetText();
textBox2.ResetText();
}
This line is wrong for two reasons
|when you should use the logical||so the correct line is
From your question is not clear if you want to reset the textbox in case of error or if you want to reset always as you do now. If you want to reset only in case of error move the two ResetText inside the if block