PDA

View Full Version : Solved: Display Character Entries in InputBox with "*"



CaptRon
03-02-2007, 11:09 AM
I often use an InputBox to require a user to type in a specific password for the macro to continue one way or another.

However, the characters are revealed as they type them in and anyone standing near the screen can see the password. Is it possible to have each character appear as asterisks when the password is typed into the space provided?

Below is a sample of how I use this MsgBox/InputBox arrangement.



Sub GoToAdjustments()

' GoToAdjustments macro to adjust mileage rates

Dim answer As String
Dim MyChar
MyChar = Chr(13)

If MsgBox("This option is provided in case there is a change in law or policy regarding travel rates and allowances." & Chr(13) + Chr(13) & "Every formula in this workbook that references these values will be updated by the change." & Chr(13) + Chr(13) & "You must enter the correct password to modify these values. Would you like to proceed?" & Chr(13) + Chr(13), vbYesNo + vbDefaultButton2, " RATE ADJUSTMENTS") = 6 Then

answer = InputBox("If tax rates, mileage rates, or other travel allowances change, the password to modify these values will be posted in the Public Folders in Outlook." & Chr(13) + Chr(13) & "Type the password below, then press the ENTER key." & Chr(13), " PASSWORD REQUIRED")

If answer = "My Password" Then
AdjustRates

ElseIf answer = "" Then

Else
If MsgBox("Not Correct. Take care to use proper case and punctuation." & Chr(13) + Chr(13) & "Example: The Lone Ranger", vbRetryCancel + vbInformation, " TRY AGAIN?") = vbRetry Then

answer = InputBox("Still having trouble? Be sure you have the correct password and try again.", " PASSWORD REQUIRED")
If answer = "My Password" Then
AdjustRates
End If
End If
End If
End If

End Sub


Thanks,

Bob Phillips
03-02-2007, 11:11 AM
Build a simple custom form and set the PasswordChar property of the textbox to *. Simplest way.

CaptRon
03-02-2007, 06:37 PM
Thank you. I'll give that a try.