Not show value

I want to hide the entered value to InputBox, using VBA codes. How?
LVL 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


You can create a user form with a textbox with PasswordChar ( for example *) to hide what is being entered

HuaMin ChenProblem resolverAuthor Commented:
Sorry, I'm only calling the codes, within Excel, and I think it is not worth of creating the form, due to such password value, within Excel file.
but the inputbox as no possibility to hide the tipped text
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

HuaMin ChenProblem resolverAuthor Commented:
Is there any other better way?
HuaMin ChenProblem resolverAuthor Commented:
Sorry, from the example, I do not see the details to hide the password. Thanks
 Option Explicit

    ' --- Global Constants (Messages) ------------------------------------
  Global gMsgText As String       'Text in MsgBox() and InputBox() functions
   Global gMsgType As Integer      'Type in MsgBox() and InputBox() functions
   Global gMsgTitle As String      'Title for MsgBox() and InputBox() function
   Global gStatusText As String    'Status bar text used in Application.Echo method

 ' API set A:
 '  Used by the callback process (TimerProc) to hook into
 '  the InputBox window
 '  Ref:

 Private Declare Function FindWindow Lib "user32" Alias _
 "FindWindowA" (ByVal lpClassName As String, _
 ByVal lpWindowName As String) As Long

 Private Declare Function FindWindowEx Lib "user32" Alias _
 "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
 ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

 Public Declare Function SetTimer& Lib "user32" _
 (ByVal hwnd&, ByVal nIDEvent&, ByVal uElapse&, ByVal _

 Public Declare Function KillTimer& Lib "user32" _
 (ByVal hwnd&, ByVal nIDEvent&)

 Private Declare Function SendMessage Lib "user32" Alias _
 "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
 ByVal wParam As Long, lParam As Any) As Long
 ' Constants for API set A
 Public Const NV_INPUTBOX As Long = &H5000&

 Public Function TimerProc(ByVal lHwnd&, ByVal uMsg&, _
 ByVal lIDEvent&, ByVal lDWTime&) As Long
   Dim lTemp As Long
   ' This function allows for a mask character on an inputbox
   '    ' Usage (Replace anything between [] with valid names from your project):
   '  From a form or module:
   '  1. Declare a Long variable
   '  2. Call the timer function:  [variable] = SetTimer([form].Hwnd, NV_INPUTBOX, [elapsed time], AddressOf [function name])
   '  2b. Example usage from a form: lTemp = SetTimer(Me.Hwnd, NV_INPUTBOX, 1, AddressOf TimerProc)
   '  3. Create your InputBox as usual
    Dim lEditHwnd As Long
   ' Find a handle to the InputBox window, then to the textbox
   ' the user types in (Known as "Edit")
   '    ' **This part is VERY important, here is how the FindWindowEx call should look:
   ' **Only change the parameters that are enclosed in [ ] in the following example
    lTemp = FindWindowEx(FindWindow("#32770", "[gMsgText]"), 0, "Edit", "")
    lEditHwnd = FindWindowEx(FindWindow("#32770", gMsgTitle), 0, "Edit", "")
   ' Send the mask character to the target InputBox when the user types
   ' The mask character in this sample is the Asc("*") - the "*" can be changed
   ' to whatever you like.
   Call SendMessage(lEditHwnd, EM_SETPASSWORDCHAR, Asc("#"), 0)
   ' Destroy the timer object when done (The user clicks OK or Cancel from the InputBox)
   KillTimer lHwnd, lIDEvent

 End Function
Sub test()
   gMsgTitle = "MsgTitle"
   gMsgType = vbOKOnly + vbInformation
   gMsgText = "MsgText"
   Dim lEditHwnd As Long
   Dim lTemp As Long
   Dim sPwd As String
   lTemp = SetTimer(Application.hwnd, NV_INPUTBOX, 1, AddressOf TimerProc)
   sPwd = InputBox(gMsgText, gMsgTitle)
   MsgBox "the password you entered was: " & sPwd
End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.