Introduction: How to Make a Login Form in Visual Basics 2010
I am going to teach you how to make a login form in Visual Basics. These can be used for a bunch of things, such as if you are making an email program, you can keep it protected by using this, or if you are making a VB operating system, you can lock your account with this. Lets get to it!
Step 1: Creating the Form
Make a form and remove the text and change "Show Icon" to false. You don't have to disable the icon, but in my opinion, it looks much nicer without it.
Step 2: Add the Interface
Add 2 labels, 2 textboxes, and 1 button.
Change label 1's text to "Username", and label 2's text to "Password", then the button's text to "Login".
The labels will be used to mark which textbox is which. Usually, I put the username textbox on the top, and the password textbox on the bottom, mainly because most login forms use this format. The button will be used to submit the information.
Step 3: Inserting the Code...
Double click the button, and put the following code in:
If TextBox1.Text = "username" And TextBox2.Text = "password" Then Form2.ShowDialog() Else MsgBox("Sorry, The Username or Password was incorrect.", MsgBoxStyle.Critical, "Information")
(Ignore the code in the image, i was tired and wrote the wrong code, haha)
This is basically telling it that if the data entered is "username" and "password", then it needs to show Form2. It also tells it that if the data entered is anything else, to show a message saying that the information was wrong, and that the person needs to reenter it.
Go to properties for the second TextBox (or which ever textbox is your password textbox) and then change the PasswordChar to '*'. This hides your password, so that nobody can see it.
Step 4: The Finished Project
Add a second form (what the login form will lead you to when you enter the correct information), and then you are done with the login form!
If you have any questions, feel free to comment! :)
1 Person Made This Project!
- luhanmarjorie made it!