Results 1 to 4 of 4

Thread: Password character blanking

  1. #1
    kevsmart
    Guest

    Question Password character blanking

    I am trying to password protect a form, and I don't want to access the registry so I don't want to use the Login form that is built in. All I am using is an input box. I want to be able to replace the characters the user types in with * so no one else can see the password, but I don't know how to do it in an input box, or if it can even be done. Any ideas?

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'Set the input of an input box to password characters 
    
    
    '---bas module code-- 
    Option Explicit 
    
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 
    
    Public 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 lpTimerFunc&) 
    
    Public Declare Function KillTimer& Lib "user32" (ByVal hwnd&, ByVal nIDEvent&) 
    Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long 
    Public Const NV_INPUTBOX As Long = &H5000& 
    Public Const EM_SETPASSWORDCHAR = &HCC 
    Public Sub TimerProc(ByVal hwnd&, ByVal uMsg&, ByVal idEvent&, ByVal dwTime&) 
    Dim myHwnd As Long 
    'Change here App.Title (defoult InputBox Caption) into your caption 
    myHwnd = FindWindowEx(FindWindow("#32770", App.Title), 0, "Edit", "") 
    Call SendMessage(myHwnd, EM_SETPASSWORDCHAR, 42, 0) 
    KillTimer hwnd, idEvent 
    End Sub 
    
    '--Using - form code: 
    Private Sub Command1_Click() 
    Dim sPass As String 
    SetTimer hwnd, NV_INPUTBOX, 10, AddressOf TimerProc 
    sPass = InputBox("Set Password") 
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

  4. #4
    kevsmart
    Guest
    Thanks, the inputbox form is working for me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width