Welcome to Logically Proven blog.
This post demonstrates how to hide the password text in a text box control using Excel VBA (Visual Basic for Applications).
First design the user form as shown in the picture below -
This form contains two textbox controls - one for Username and other for password, labels and two buttons.
In the properties window (press F4 in see properties in code window) of password textbox control - change the value of PasswordChar to '*'.
This will enforce the application to show all the characters in a password textbox control as "****".
If this property value is empty, the characters are visible to the users.
If you want to display other than '*' you can change the character that you wish. Here changed to '$'.
You are restricted to enter only one character in PasswordChar property of a textbox control. Even if you try to enter more than one character, the first character will be taken into account and the remaining characters will be removed automatically from this property box.
Events:
Double-click anywhere on the form to create the form initialize event to set the default values or do you want to perform some tasks before login form open.
Double click on the buttons to create the respective events of the buttons.
Please find the sample codes of button events.
Sample Ok button code:
Sample Cancel button code: To close the form
Please write your comments if you find anything is incorrect or do you want to share more information about the topic discussed above.
Logically Proven
Learn, Teach, Share
This post demonstrates how to hide the password text in a text box control using Excel VBA (Visual Basic for Applications).
First design the user form as shown in the picture below -
This form contains two textbox controls - one for Username and other for password, labels and two buttons.
In the properties window (press F4 in see properties in code window) of password textbox control - change the value of PasswordChar to '*'.
This will enforce the application to show all the characters in a password textbox control as "****".
If this property value is empty, the characters are visible to the users.
If you want to display other than '*' you can change the character that you wish. Here changed to '$'.
You are restricted to enter only one character in PasswordChar property of a textbox control. Even if you try to enter more than one character, the first character will be taken into account and the remaining characters will be removed automatically from this property box.
Events:
Double-click anywhere on the form to create the form initialize event to set the default values or do you want to perform some tasks before login form open.
Private Sub UserForm_Initialize() 'perform actions before opening the login form End Sub
Double click on the buttons to create the respective events of the buttons.
Please find the sample codes of button events.
Sample Ok button code:
Private Sub cmdOK_Click() 'validate the controls If txtUserName.Value = "" Or txtPassword.Value = "" Then MsgBox "Please enter valid username and password" Exit Sub End If 'do your work 'close the form Unload frmLogin End Sub
Sample Cancel button code: To close the form
Private Sub cmdClose_Click() 'close the form Unload frmLogin End Sub
Please write your comments if you find anything is incorrect or do you want to share more information about the topic discussed above.
Logically Proven
Learn, Teach, Share
Thanks dear,
ReplyDeleteYour suggestion is helped a lot !
I was searching pswrd ** char. and was not getting easy way to hide the text.
your suggestion is acceptable
Thank you for your comment.
Deletethanks
ReplyDeleteThank you :)
DeleteI really enjoy reading and also appreciate your work. hide my wp
ReplyDeleteWhen your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your. hide wordpress plugin
ReplyDeleteThis is a good post. This post gives truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. Thank you so much. Keep up the good works. Hide My WP
ReplyDelete