Instructables

How to make a login form in Visual Basics 2010

Picture of How to make a login form in Visual Basics 2010
Login Screen2.png
Login Screen3.png

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!

 
Remove these adsRemove these ads by Signing Up

Step 1: Creating the form

Picture of 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

Picture of 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...

Picture of 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 wrong.", 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.

Optional:

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

Picture of The finished project
Login Screen2.png
Login Screen3.png

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! :)

Nice instructable. You just helped me figure out what the line of code i was needing for my other project, so thanks.
farmerboyk (author)  hightekrednek23962 years ago
Your welcome:) I'm thinking about making a tut for a maze game i made. Maybe tomorrow... :3 its really fun :}
i made a game too did u use the tutorial from microsoft
farmerboyk (author)  hightekrednek23962 years ago
No, I actually haven't used any tutorials from microsoft, just a few videos(not on there site) on how to learn the language.