ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

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.

  1. 'CHECKING IF THE CHECKBOX WAS CHECKED OR NOT.
  2.         If CheckBox1.CheckState = CheckState.Checked Then
  3.             'IF TRUE, IT SHOW THE TEXT  
  4.             txtpass.UseSystemPasswordChar = False
  5.         Else
  6.             'IF FALSE, IT WILL HIDE THE TEXT AND IT WILL TURN IT INTIO BULLETS.
  7.             txtpass.UseSystemPasswordChar = True
  8.         End If

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

  1. 'HIDE THE TEXT OF THE TXTPASS ON THE FIRST LOAD
  2.         txtpass.UseSystemPasswordChar = True

These are the full codes that you have made.

  1. Public Class Form1
  2.     Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
  3.         'CHECKING IF THE CHECKBOX WAS CHECKED OR NOT.
  4.         If CheckBox1.CheckState = CheckState.Checked Then
  5.             'IF TRUE, IT SHOWS THE TEXT  
  6.             txtpass.UseSystemPasswordChar = False
  7.         Else
  8.             'IF FALSE, IT WILL HIDE THE TEXT AND IT WILL TURN INTO BULLETS.
  9.             txtpass.UseSystemPasswordChar = True
  10.         End If
  11.     End Sub
  12.  
  13.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  14.         'HIDE THE TEXT OF THE TXTPASS ON THE FIRST LOAD
  15.         txtpass.UseSystemPasswordChar = True
  16.     End Sub
  17. End Class

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

Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!