0

Hi
In my windows application i have a combobox() and textbox().I want to show a messagebox if cmb1 is 0 and txtbx1 or txtbx2 is empty.The below code doesnt work.It shows the Messagebox even when cmb1== 0 and txt1 is empty


if ((cmb1.Text != "0" &&( txtbx1.Text ==""|| txtbx2.Text =="" ))
{
MessageBox.Show();
}
Can anyone help with the code
thanx in Advance

4
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by darkocean
0
if ((cmb1.Text == "0") && (string.IsNullOrEmpty(txtbx1.Text) || string.IsNullOrEmpty(txtbx2.Text)))
      {
        MessageBox.Show("empty");
      }
0

Hi
thnx for your effort but it didnt work.Still the same problem occurs.Do you have any idea?

0

Please confirm the desired logic:

IF (comboBox = "0") AND 
(
  (tb1 is empty)
  or
  (tb2 is empty)
)

Per what you said it works... I think you're explaining your logic incorrectly or the controls aren't returning the value you expect.

0

What do you mean exactly when you say cmb1== 0
Do you mean : the combobox is empty or the combobox contains a "0"?

0
if ((cmb1.SelectedItem.ToString == "0") && (txtbx1.Text = " ") || (txtbx2.Text = " ")))
      {
MessageBox.Show("empty");
      }
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.