• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Password should be shown like "*****"

smittal

Member
Dear All,

i had tried to get the result through search option but not get the extact answer what i am looking for.

refer below mention code, whenever i entered my password, it shows the exact words, (what my password is) in Input option, but i want it should show the "*******....." instead of the same characters. (Currently my password option make no sense) code is:-Sub master()

' Keyboard Shortcut: Ctrl+j

Dim scon As String
Dim con As New ADODB.Connection
Dim rs As New Recordset
Dim lctr As Long
Dim ans As String
Dim unm As String
Dim start As Range
Dim Message As String, Title As String, Default As String, MyValue As String


Application.ScreenUpdating = False
Application.DisplayAlerts = False

Message = "Access by sanchit only" & Chr(10) & Chr(10) & "Please Enter the Password" ' Set prompt.
Title = "Sales Dashboard of Internet Moguls...." ' Set title.
Default = "Please Enter the Password" ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)

I f MyValue = "babbar" Then
Executable code
End if
Many thanks in advance for same.
 
I don't think you can do that with a basic inputbox. You can do it pretty easily with a custom form though.
 
Hi Smittal,

I doubt, you can do this with the Inputbox unless if there is anyway with the API functions .Otherwise, you can create a Userform with a textbox on it and set the PasswordChar property of the text box to asterisk (*).
 
Hi, smittal!

Give a look at the attached file. It has 2 command button controls and 1 text box control, hidden by default.
1st command button makes textbox visible and you can enter anything password masked. 2nd button hides the textbox and displays the entered text; you should do whatever you need with it.

This is the code for the required events:
Code:
Option Explicit
 
Private Sub cmdGetPassword_Click()
    txtPassword.Visible = True
End Sub
 
Private Sub cmdResetPassword_Click()
    txtPassword.Visible = False
End Sub
 
Private Sub txtPassword_GotFocus()
    txtPassword.Text = ""
End Sub
 
Private Sub txtPassword_LostFocus()
    txtPassword.Visible = False
    Debug.Print txtPassword.Text
End Sub

Just advise if any issue.

Regards!
 

Attachments

  • Password should be shown like (for smittal at chandoo.org).xlsm
    25.5 KB · Views: 6
Thanks Sirjb7, but please confirm where we get the result of "debug.print" command. i am not able to see the result after click on command 2.
 
Hi, smittal!

Let me explain how it works:

a) There's a textbox control txtPassword which by default is hidden, and 2 command buttons just for testing purposes: cyan command button enables the input in the hidden textbox, entered text is held in Text property of textbox until violet command button empties it.

b) After running the code of click event of cyan command button, the textbox gets visible, the user input the password there, it's not shown but as wildcards, and when he quits the input on the textbox, i.e., lost focus event is triggered, the textbox becomes hidden again, and the entered password is printed to the immediate window thru the Debug.Print method: you should replace this line for the proper code to store that value where the rest of your code requires it.

Hope it helps.

Regards!
 
Hi, smittal!
For a simpler implementation you'd set the Visible property of the textbox to True in design mode and keep only the lost focus event code. Doing so you'll have always visible the textbox (displaying asterisks) and in the lost focus you'd make the required validations.
Regards!
 
Back
Top