Hide Login Password Inputted into Textbox For GURUS

kpark91

Well-known Member
Joined
Jul 15, 2010
Messages
1,582
Hello,
I am currently trying to create a login screen and I have done so with 2 simple labels and 2 textboxes.

On the labels the texts were "Login ID:" and "Password:" (not important)

On the textboxes, they were just blank for user input. Their names are "ID" and "pwd"

The problem I am having is that I need to protect the password from being viewed just like you would see from logging into this website.
So, this means that any keys the user inputs into pwd textbox, it would have to appear as * for each character!

This code works fine when the user inputs a character by character or copy+paste:
Code:
Option Explicit
Private strPwd As String, lenStrPwd As Integer, lenPwd As Integer
 
Private Sub pwd_Change()
    With LoginMenu
        lenPwd = Len(.pwd.Text)
        lenStrPwd = Len(strPwd)
        If lenStrPwd < lenPwd Then
            strPwd = strPwd & Right$(.pwd.Text, 1)
            .pwd.Text = fillWAstricks(lenPwd)
        Else
            strPwd = Left$(strPwd, lenPwd)
        End If
    End With
End Sub
 
Private Function fillWAstricks(intChar As Integer) As String
    Dim i%
    
    For i = 1 To intChar
        fillWAstricks = fillWAstricks & "*"
    Next i
End Function

But when a text is highlighted and replaced with an input (without erasing the highlighted region), it shows the input.

Is there a way around this?


Please and thank you in advance,
Kpark
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
See the PasswordChar property of an ActiveX textbox.
 
Last edited:
Upvote 0
That was perfect, Mr. or Mrs. Shg!

You have no idea how long I have tried to fix this problem.

Thank you so much!
kpark
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,219
Members
452,895
Latest member
BILLING GUY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top