Excel Textbox with PasswordChar RRS feed

  • Question

  • Hi,

    We have a VBA application that has been working for some time.  Recently we had a client that reported that it was not working.  After troubleshooting the issue, we discovered that a textbox that is used to get the password for logging in did not have the correct value when retrieving it.  ( dim pwd as string    pwd = textbox1.text)  the value of the string pwd only contained question marks.  I checked the keypress event and the keyascii variable had the "?" in it.  The version of Office is 2013.   Some computers work correctly and some don't. 

    Can anyone think of what might cause this?



    Friday, September 9, 2016 1:45 PM

All replies

  • Hi,

    >>the keyascii variable had the "?" in it

    Do you mean the keyascii value of the text is "?" instead of number?


    What kind of characters do you use as the password? English Letters or others?

    If all input would be "?" for the textbox?

    Do you compare the system Region settings of the computers which could output successfully with which could not?

    I would suggest you try to change Language for non-Unicode programs in Region settings.

    It is in Control Panel\Clock, Language, and Region -> Change date, time, or number formats ->Administrative tab

    Monday, September 12, 2016 8:18 AM
  • Hi,

    KeyAscii is passed to the keypress event of the textbox.  Normally it is the value of the key typed in by the user.  After the data is typed in to the textbox, the value is retrieved by accessing the textbox1.text property and is supposed to be the text the user typed in.  In the case where we are getting the error, only question marks are retrieved when using  pwd = textbox1.text.  I looked at the language in regional settings but didn't see anything that would help.


    Monday, September 12, 2016 12:56 PM
  • I suggest you do it over again as of Celeste Li's instructions regarding Non-Unicode programs.

    Your line

    I looked at the language in regional settings but didn't see anything that would help

    is not helpful.

    Best regards, George

    Monday, September 12, 2016 2:24 PM
  • Thanks for your suggestion but the setting is English (United States) on the computers that work and the ones that don't work.  Are you saying that our client should just change it to something else because of a bug in windows?

    Thursday, September 15, 2016 6:30 PM
  • Hi,

    I am referring to Language for non-Unicode programs.

    The setting of  is shown as below. It controls the language used when displaying text in programs that do not support Unicode.

    What characters would be used as password? If the characters is non-unicode, it would be printed as "?".

    Friday, September 16, 2016 5:50 AM
  • Hi,

    Yes, that is the setting we checked and it is set to English on both the computers that work and the ones that don't.  Here's how the program is set up as a test:

    In Excel, I added a userform and a textbox.  I set the textbox passwordchar to "*"  I then added a msgbox to the textbox1 change event. (Msgbox(textbox1.text)   When the value of textbox changes by typing in a character, the msgbox displays the value of the textbox.   On the computers that work, it displays the text in English characters like "password"   On the computers that don't work, it displays the value as question marks like "????????".

    Thanks for you help.

    Friday, September 16, 2016 8:19 PM
  • I think the issue might cause from the control itself, I suggest you try to repair the Office application.
    Monday, September 19, 2016 8:58 AM
  • Thanks,

    I have had our customer repair the Office installation and there is no change.  Do you know which DLL the textbox control is in so maybe I could compare the versions of it; or, do you know of any method to troubleshoot to a detailed level?


    Wednesday, September 21, 2016 1:11 PM
  • Hi,

    In that situation, I still want to check the environment.

    What is your language for your OS and Office?

    Please try:

    1)type number as 123456 check if the MsgBox could return correctly.

    2)do not set the passwordchar, check if the string could show as normal and if MsgBox could return correctly.

    3)Type string directly in the Immediate Windows in the VBE check if it shows correctly.

    Thursday, September 22, 2016 7:33 AM
  • Good Morning,

    I am the customer that Lloyd is trying to help.

    I recorded a short video and posted it to my Dropbox here:


    The issue arose when we started upgrading PCs to HP EliteOne 800 G3 desktops and EliteBook 800 G1, G2 and G3 laptops.

    We have been round and round trying to figure this out and then Lloyd and his team meticulously went through the code and discovered that the users were locking themselves out because in the real plugin the text box is for a password. Which is the reason for the asterisks.

    Thank you for your review of this!

    Have a great day!


    Thursday, September 22, 2016 12:43 PM
  • Hello Again!

    So one of our dev. guys has been researching too and has discovered the following occurs when he creates a user form with the following fields using the script below -- It looks to be Chinese possibly:


    Private Sub CheckBox1_Click()

    TextBox1.PasswordChar = IIf(CheckBox1, "", "*")

    Label2.Caption = TextBox1.Value

    End Sub

    Private Sub CommandButton1_Click()

    MsgBox (TextBox1.Value)

    End Sub

    Private Sub CommandButton2_Click()

    Label1.Caption = TextBox1.Value

    End Sub

    Private Sub Label2_Click()

    Label2.Caption = TextBox1.Value

    End Sub

    Private Sub TextBox1_Change()

    Label2.Caption = TextBox1.Value

    End Sub

    Sorry for the links instead of pics or attachments -- silly thing says it has to verify my account before I can post those. Thing is, I haven't seen any verification email..... Have to look into that next.

    Thursday, September 22, 2016 2:44 PM
  • Hello,

    What is your language setting for your OS and Office? What is the version of Office for this client PCS?


    Please try add a textbox in the worksheet instead of the userform to test the passwordchar.

    Please try to create a Windows Form Application and test textbox with passwordchar.


    >>The issue arose when we started upgrading PCs to HP EliteOne 800 G3 desktops and EliteBook 800 G1, G2 and G3 laptops.


    Do the issue occur on this specific PC? If the issue occurs for other PCs use HP EliteOne 800 G3 desktops and EliteBook 800 G1, G2 and G3 laptops?

    Friday, September 23, 2016 10:10 AM