Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
[removed duplicate posting of code - see "What have I tried?" section below]

ty for your helps

What I have tried:

private void button1_Click(object sender, EventArgs e)
       {
           Form2 frm = new Form2();
           string username = "Vector";
           int number = 89-2;
           string password = "Vector" + number.ToString();
           if ((txtusername.Text == username) && (txtpassword.Text == password))
               this.Hide();
               frm.Show();
               MessageBox.Show("Welcome MR.Vector");
           else
               MessageBox.Show("Do not try to open this program");
           this.Close();
       }
Posted
Updated 6-Sep-17 12:37pm
v5
Comments
Graeme_Grant 6-Sep-17 18:37pm    
Don't post code twice - it wastes everybody's time reading it twice!

1 solution

You are not using braces to group multiple lines of code in the if / else statement. Only VB allows this.

C# '101' - It should be:
C#
if ((txtusername.Text == username) && (txtpassword.Text == password))
{
    this.Hide();
    frm.Show();
    MessageBox.Show("Welcome MR.Vector");
}
else
{
    MessageBox.Show("Do not try to open this program");
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900