Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleAllow the user to enter "super user" mode by entering a password
Keywordssuper user, password
CategoriesMiscellany, 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.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated