Excel 7 has built-in password support for displaying asterisks when a user types into an edit box.
The GetPassword function available in the downloadable workbook below returns the text a user types into an edit box while displaying asterisks for each character. Excel 7 has built-in password support but Excel 5 requires a workaround to simulate a password edit box. The included function calls the same dialog box but configures it for the appropriate version. We have designed this so that the user experience is as similar as possible in both versions.
The Excel 7 version correctly handles all possible user actions (using the built-in support). This includes deleting the first character, final character, and/or replacing any characters a user selects before typing.
In Excel 5, you use a hidden edit box (outside the dialog frame) as the true input control while the user views a second edit box. You monitor each character the user types into the hidden edit box and place an asterisk in the viewed box. This simulates the behavior of the property available in Excel 7.
The Excel 5 code is a hack, it handles all major cases including using the delete or backspace key to remove one character at a time, replacing highlighted asterisks at the end with a different character and deleting a group of characters from the end of string of asterisks. There are a few actions that are impossible to trap. These include replacing the first character and/or replacing/deleting characters in the middle of the string.
Download Baarns
Password Function Now!(45K - xls format)
Information provided in this document is provided "as
is" without warranty of any kind, either expressed or
implied, including but not limited to the implied warranties of
merchantability and/or fitness for a particular purpose. The user
assumes the entire risk as to the accuracy and the use of this
information.
The name is Baud......, James Baud. |
Copyright© 1996-1999, Baarns Consulting Group, Inc. - All rights reserved. |