Consulting

Results 1 to 6 of 6

Thread: Input box to display as ******

  1. #1
    VBAX Contributor
    Joined
    Jun 2019
    Posts
    155
    Location

    Input box to display as ******

    Hi ,

    I am having the following code.


    Dim PassProtect As Variant    If pblnEnteredPassword Then GoTo DoStuff
        PassProtect = InputBox("Enter password to print calibration certificate soft copy" & vbCrLf, Title:="Control Panel")
          If PassProtect = vbNullString Then Exit Sub
        If PassProtect = "Boffice" Then
            pblnEnteredPassword = True
            GoTo DoStuff
        Else
            MsgBox Prompt:="Incorrect password. Please try again.", Buttons:=vbOKOnly
            Exit Sub
        End If
    DoStuff:
    I this when i enter my password it should display as ****** on my Inputbox

    Can any one please help me to solve this

  2. #2
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Set the PasswordChar to * in properties.

    Oops! That's for a TextBox on a UserForm.
    Last edited by paulked; 10-12-2019 at 11:18 AM. Reason: Missed the InputBox!
    Semper in excretia sumus; solum profundum variat.

  3. #3
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    Semper in excretia sumus; solum profundum variat.

  4. #4
    VBAX Contributor
    Joined
    Jun 2019
    Posts
    155
    Location
    I had created the user form. But i don't know how to write the code for that.

  5. #5
    VBAX Master paulked's Avatar
    Joined
    Apr 2006
    Posts
    1,007
    Location
    You've got the code in your first post!
    Semper in excretia sumus; solum profundum variat.

  6. #6
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    You can't do that with an Inputbox; Use a TextBox on a UserForm.

    Option Explicit
    
    'Allow multiple passwords
    Const PWList As String = "Boffice, Foffice, GoOD1pA$$WOrd:
    
    Dim PW As String
    Dim Stars As String
    
    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    'You might need to experiment with Shift
    
    'Save the Keystroke
       PW = PW & ChrW(KeyCode)
       Stars = Stars & "*"
    End Sub
    
    Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    'Display asterisks
       TextBox1 = Stars
    End Sub
    
    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    'Finished entering PW
       Stars = ""
       CheckPW
    End Sub
    
    Private Sub CheckPW()
       If PW = vbNullString Then Exit Sub
       If Instr(1, PWList, PW) Then
          PW = ""
          DoStuff
       Else
          MsgBox Prompt:="Incorrect password. Please try again.", Buttons:=vbOKOnly
          PW = ""
       End If
    End Sub
    
    Private Sub DoStuff()
    'Fill in the blank
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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