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

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

DarkS25 months ago

nice codes.. it helps me ....

by the way can you show me step by step how to create and add an icon???

did not open the login form opened form

farmerboyk (author)  ANAS_ARKAWİ_326 months ago

At the time of making the tutorial, all of the code worked. Are you certain you copied it entirely? If you're using this with a newer VB, things may be different so it might not work.

BenjaminH111 months ago

Great code! I love it!

farmerboyk (author)  BenjaminH16 months ago

Thanks! Its doing quite well for something I made when I was twelve haha

andrew.trow19 months ago

i have a question . how do i make an actual useable login screen . like one where a person can create his own user and password . This is for my ICT project . so would really appreciate all the help i can get. here is my email ID " ". any help can be sent to my email . Thanks :)

farmerboyk (author)  andrew.trow16 months ago

Hello! Sorry for the late response. I haven't used VB in a very long time, so I'm not sure. Sorry!

DodoW8 months ago


DodoW8 months ago


DodoW8 months ago


DodoW8 months ago


DodoW8 months ago