|
|
Title | Allow the user to enter "super user" mode by entering a password |
Keywords | super user, password |
Categories | Miscellany, Software Engineering |
|
|
Set KeyPreview = True on the form. In the KeyDown event handler, keep track of the keys pressed looking for the magic word.
|
|
Private Sub Form_KeyDown(KeyCode As Integer, Shift As _
Integer)
Const MAGIC_WORD = "HELLO" ' Use all caps.
Static key_so_far As String
Dim new_key As String
key_so_far = key_so_far & Chr$(KeyCode)
If Left$(MAGIC_WORD, Len(key_so_far)) <> key_so_far Then
' It's no good. Start over.
key_so_far = ""
Else
' See if it's a match.
If MAGIC_WORD = key_so_far Then
MsgBox "You entered the key"
key_so_far = ""
End If
End If
End Sub
|
|
This method provides a low-tech way to get into special program functions, display super user commands, etc. It's not very secure so you should probably disable it before shipping a final product.
|
|
|
|
|
|