• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Masking Password in InputBox

Status
Niet open voor verdere reacties.

danny147

Terugkerende gebruiker
Lid geworden
29 apr 2007
Berichten
4.744
Beste,

Graag zou ik tijdens het intypen van Paswoord dat er "***" te zien zijn
Op het internet gekeken, maar blijkbaar zou er iets zijn met 64 bit systeem ? --> Daniel Klann

Gebruik volgende code:

Code:
Private Sub CommandButton1_Click()
Dim sh As Worksheet

Application.ScreenUpdating = False

x = InputBox("Wachtwoord ingeven a.u.b.", "Wachtwoord.")

If x = "SIDDESD" Then
    MsgBox "Welkom", vbOKOnly, "Wachtwoord"
    
    For Each sh In Sheets
        sh.Unprotect Password:="1234"
    Next sh
    
    UserForm5.Show

Else
    MsgBox "Verkeerd Paswoord !", vbOKOnly, "Wachtwoord"
    
Exit Sub
End If

    For Each sh In Sheets
        sh.Protect Password:="1234", AllowFiltering:=True
    Next sh
    
Application.ScreenUpdating = True

End Sub
 
Gebruik een userform. Het TextBox control heeft een PasswordChar eigenschap.
 
Daniel Klann's methode gebruikt een aantal 32 bit api-functies,
wellicht wil iemand deze ombouwen naar 64-bit (indien mogelijk)

maar de suggestie van JKP is makkelijker en veel minder omslachtig

de api-functies:

Code:
Private Declare Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" _
(ByVal hDlg As Long, ByVal nIDDlgItem As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, _
ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetModuleHandle Lib "kernel32" Alias _
"GetModuleHandleA" (ByVal lpModuleName As String) As Long
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" _
(ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, _
ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
 
Is al gedaan; Dit zouden ze moeten zijn

Code:
Private Declare PtrSafe Function CallNextHookEx Lib "user32" (ByVal hHook As LongPtr, ByVal ncode As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr
Private Declare PtrSafe Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As LongPtr
Private Declare PtrSafe Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As LongPtr, ByVal hmod As LongPtr, ByVal dwThreadId As Long) As LongPtr
Private Declare PtrSafe Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As LongPtr) As Long
Private Declare PtrSafe Function SendDlgItemMessage Lib "user32" Alias "SendDlgItemMessageA" (ByVal hDlg As LongPtr, ByVal nIDDlgItem As Long, ByVal wMsg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
Private Declare PtrSafe Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As LongPtr, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare PtrSafe Function GetCurrentThreadId Lib "kernel32" () As Long
 
Bedankt allen voor het meedenken :)

Het idee van jkpieterse lijkt dan de beste oplossing tezijn :thumb:
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan