How to Hide and Show the Password Using a CheckBox in VB.Net

1
4150

This tutorial is all about How to Hide and Show the Password Using a CheckBox in VB.Net.
Today, I will teach you how to set your Textbox to “show” and “hide” Password in the User Rgistration Form by using Visual Basic 2008. This will help you determined the password that you have input in the Textbox when registering in the User Registration Form.

So let’s begin:

Open the Visual Basic 2008 and create a new Windows Form Application. After that, do the Form just like this.

showpasswor_form

Double click the checkbox and do this following code in the method. This method will set the password into bullets to hide it, or set it into letters to know the password that you have input exactly according to your desire.

[vbnet] ‘CHECKING IF THE CHECKBOX WAS CHECKED OR NOT.
If CheckBox1.CheckState = CheckState.Checked Then
‘IF TRUE, IT SHOW THE TEXT
txtpass.UseSystemPasswordChar = False
Else
‘IF FALSE, IT WILL HIDE THE TEXT AND IT WILL TURN IT INTIO BULLETS.
txtpass.UseSystemPasswordChar = True
End If
[/vbnet]

Go back to the design views, double click the form and do this following code in the Form_Load.

[vbnet] ‘HIDE THE TEXT OF THE TXTPASS ON THE FIRST LOAD
txtpass.UseSystemPasswordChar = True
[/vbnet]

These are the full codes that you have made.

[vbnet] Public Class Form1
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
‘CHECKING IF THE CHECKBOX WAS CHECKED OR NOT.
If CheckBox1.CheckState = CheckState.Checked Then
‘IF TRUE, IT SHOWS THE TEXT
txtpass.UseSystemPasswordChar = False
Else
‘IF FALSE, IT WILL HIDE THE TEXT AND IT WILL TURN INTO BULLETS.
txtpass.UseSystemPasswordChar = True
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
‘HIDE THE TEXT OF THE TXTPASS ON THE FIRST LOAD
txtpass.UseSystemPasswordChar = True
End Sub
End Class
[/vbnet]

Now, press F5 on the keyboard to run your project.

 

Readers might read also:

 

 

Facebook Comments

1 COMMENT

  1. I see you don’t monetize your page, don’t waste your traffic,
    you can earn extra cash every month because you’ve got high
    quality content. If you want to know how to make extra bucks, search for: Mertiso’s tips best adsense alternative

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.