0

Hi,
im getting an error
'Invalid term expression else'.

private void button1_Click(object sender, EventArgs e)
        {
            ClassLogin clgn = new ClassLogin();
            bool sts =clgn.Check(textBox2.Text, textBox1.Text);
            if (sts == true)
            {
                MessageBox.Show("OK");
                else
                MessageBox.Show("Your Username or password is incorrect");
                
            }

        }

WHY?

4
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by Munnazz
0

Do it like this:

if (sts == true)            
{                
MessageBox.Show("OK");    
}            
else   
{           
MessageBox.Show("Your Username or password is incorrect");             
}
0
private void button1_Click(object sender, EventArgs e)        
{            
ClassLogin clgn = new ClassLogin();            
bool sts = clgn.Check(textBox2.Text, textBox1.Text);            
if (sts == true)            
{               
MessageBox.Show("OK");
}
else
{
MessageBox.Show("Your Username or password is incorrect");             
}
0

The syntax for if else is

if (Condition)
  {
     txtName.Text="ravi Varma";
  }
else
  {
     txtName.Text="ravi kiran varma";
  }
This question has already been answered. 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.