0
private void Login_page()
        {
            var i = 0;
            while (i < 5)
            {
                if (textBox1.Text.Equals("admin"))
                {
                    if (textBox2.Text.Equals("parth"))
                    {

                    }
                    else
                    {
                        textBox1.ResetText();
                        MessageBox.Show("passwod is wrong try agine");
                        i++;

                    }
                }
                else
                {
                    textBox2.ResetText();
                    MessageBox.Show("username and password is wrong");
                    i++;

                }
            }
            if (i == 5)
            {

                MessageBox.Show("you tried max time");
                Dispose();
            }
            else
            {
                MainMenu mainMenu = new MainMenu();
                mainMenu.Show();
                this.Hide();
            }
        }

I am tring for if inserted password and username is wrong so its give 5 time to change that but i have proble how to insert text next time in textbox. in this code loop is continusly insert blank text in textbox. so how to fix it??

2
Contributors
4
Replies
12
Views
2 Years
Discussion Span
Last Post by parth2911
Featured Replies
  • 1
    ddanbe 2,525   2 Years Ago

    Why not use Textbox.Clear instead of ResetText? Read More

  • 1
    ddanbe 2,525   2 Years Ago

    Look at the else clauses of your if statements and switch textBox1 with textBox2. Your are testing one textbox and clearing the other! Read More

1

Look at the else clauses of your if statements and switch textBox1 with textBox2. Your are testing one textbox and clearing the other!

0
private int Login_page(int i)
        {
            if (textBox1.Text.Equals("admin"))
                {
                    if (textBox2.Text.Equals("parth"))
                    {
                        MainMenu mainMenu = new MainMenu();
                        mainMenu.Show();
                        this.Hide();
                        return 0;
                    }
                    else
                    {
                        textBox2.Clear();
                        MessageBox.Show("passwod is wrong try agine");
                        if (i == 5)
                        {
                            MessageBox.Show("you tried max time");
                            Dispose();  
                        }
                        return i++;
                    }
                }
                else
                {
                    textBox1.Clear();
                    MessageBox.Show("username and password is wrong");
                    if (i == 5)
                    {
                        MessageBox.Show("you tried max time");
                        Dispose();
                    }
                    return i++;

                }

now its working..
Thank you sir..

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.