Saturday, 7 July 2018
How to create Login program Tutorial – C#.NET
This tutorial will show you how to make a login program. This is a simple login program, after understanding how it works, you can try a login program using a database
Open Visual Studio 2010 / 2013 / 2015 / 2017 Express Edition.
Click on new Project to Create:
Under template click on C#, select Windows Form Application, and enter the project name "Login" and then click Ok.
Creating new project
This will automatically create your project
You can change the form text to whatever you want to call it like "Log in Form". To do that, click on the form and then go to properties window, then change the text property.
You need to add another form to your application. To do that, click on Project on the menu bar, then click on Add Windows Form.:
A new window will appear. Click on Add:
Give it a name and click on add and it will add another form to the existing program.
Add a new Label and change it's text to whatever you like:
Go back to Form1: that was created at the first time
Add two label and textbox to the form. Change the label 1 text to "Username" and label 2 to Password.
We need the change the password text property. Right click on the textbox that will hold the password, click on properties, and go to the properties window. Change the PasswordChar property to * :
Add a button to the form and change it's text to "Login"
The form will look like this:
Suppose we want the username = log and the password = 12345
Double click on the button and add the following button click event code
if (textBox1.Text=="Log"||textBox2.Text=="12345")
{
Form2 ff = new Form2();
this.Hide();
ff.ShowDialog();
}
else{MessageBox.Show("Invalid Password or Username", "MY APPLICATION", MessageBoxButtons.OK, MessageBoxIcon.Error);}
You can change the username and the password in the code where it says "Log" for the username and "12345" for the password.
Run the program and it should work fine.
If you enter a wrong username or a wrong password, you should get the following message:
If you enter the right username and the right password, the second form will appear:
Now that you learned the idea of how login works, you can use the a database to save usernames and passwords and check if the user supplied the right credentials in the next tutorial
DOWNLOAD VIDEO TUTORIAL How to create Login program Tutorial – C#.NET
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment