The Text property of a TextBox will never be
null
- it can be the empty string, but it's never null.
So this test:
if (txt_P2In.Text == null || txt_Vol1In.Text == null || txt_Vol2In.Text == null || txt_U1In.Text == null || txt_U2In.Text == null || txt_vel1In.Text == null || txt_vel2In.Text == null || txt_h1In.Text == null || txt_h2In.Text == null || txt_QIn.Text == null || txt_WIn.Text == null)
will never succeed.
Instead check each textbox with:
if (string.IsNullOrWhitespace(txt_P2In.Text) || string.IsNullorWhiteSpace(...
Personally, I'd use a method:
private bool IsAnyFieldEmpty(params TextBox[] boxes)
{
foreach (TextBox box in boxes)
{
if (string.IsNullOrWhiteSpace(box.Text)) return true;
}
return false;
}
And call it like this:
if (IsAnyFieldEmpty(txt_P2In, txt_Vol1In, txt_Vol2In, txt_U1In,
txt_U2In, txt_vel1In, txt_vel2In, txt_h1In,
txt_h2In, txt_QIn, txt_WIn.Text))