Can anyone see why this would fail?

Sven62

Active Member
Joined
Feb 21, 2012
Messages
485
The following code worked fine until some of the computers were upgraded to Windows 10 from Windows 7.

The upgraded computers work fine except for this code. The textbox appears and the correct password is entered... then they get "The password was wrong, try again." WHY!!!!!???? I do not understand!! Someone? Anyone?

Is there a better way to write this? Obviously the goal is a password textbox that will accept the correct password like it used to do. TIA!

Code:
[COLOR=#333333]Private Sub UserForm_Activate() With UserForm13[/COLOR]   .Top = Application.Top + 275
   .Left = Application.Left + 200
 End With
End Sub


Private Sub CommandButton1_Click()


Dim strPass As String


strPass = "nakosi"


If TextBox1.Value = strPass Then
    Call UnprotectAllSheets
    Unload Me
Else
    If MsgBox("The password was wrong, try again", vbYesNo) = vbNo Then
        Unload Me
    Else
        TextBox1.Value = ""
        TextBox1.SetFocus
    End If
End If [COLOR=#333333]End Sub[/COLOR]
 
Where is the password masking coming from? I haven't done that in ages - is it something in the userform textbox properties?

Yup. You can select any character. I was using an asterisk. I tried other characters - they didn't work. Only removing the mask or changing the password to no password would allow the form to work on the Win 10 Ent. machines.
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try this and tell us the output you get in the immediate window :

Code:
Private Sub CommandButton1_Click()

    Dim strPass As String
    
    strPass = "nakosi"
    
    [COLOR=#ff0000][B]Debug.Print strPass & vbTab & TextBox1.Value[/B][/COLOR]
    [B][COLOR=#ff0000]Debug.Print strPass & vbTab & TextBox1.Text[/COLOR][/B]
    
    
    If TextBox1.Value = strPass Then
        Call UnprotectAllSheets
        Unload Me
    Else
        If MsgBox("The password was wrong, try again", vbYesNo) = vbNo Then
            Unload Me
        Else
            TextBox1.Value = ""
            TextBox1.SetFocus
        End If
    End If


End Sub
 
Upvote 0
No output. I tried it on a computer the masked textbox works on. I do not have ready access to the Win 10 Ent computers that are having the problem. Should there be an output on a computer that is not having any problems?
 
Upvote 0
Just noting that there definitely should be output. Are you looking in the right place? Output would be to the immediate window in the vba environment.
 
Upvote 0
Nothing happens. The password is accepted and the macro runs normally. Nothing in the VBA environment.
 
Last edited:
Upvote 0
Nothing happens. The password is accepted and the macro runs normally. Nothing in the VBA environment.

Try displaying the output in a MsgBox as follows :
Code:
    [B]MsgBox[/B] strPass & vbTab & TextBox1.Value
    [B]MsgBox[/B] strPass & vbTab & TextBox1.Text
 
Upvote 0
OK THAT worked. But it worked on my home computer which doesn't have a problem. It returned nakosi nakosi.

I will check this on the problem computers. Now, the question is.... what do you expect will happen? How to proceed if it returns the correct words? How to proceed if it returns ******?

I very much appreciate your help with this.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

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