Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

activating an easter egg 1

Status
Not open for further replies.

draugen

Programmer
Nov 24, 2004
48
0
0
NO
I need to activate an easter egg when the user writes "vinner", just by using the keyboard (i.e. no text box). Can anybody point me in the right direction.
Thanks ahead of time.
 

How about (one empty Form)
Code:
Option Explicit
Dim str As String

Private Sub Form_Load()
    Me.KeyPreview = True
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    str = str & Chr(KeyAscii)
    
    If str = "vinner" Then
        MsgBox "You have opened an easter egg."
    End If
End Sub

Have fun.

---- Andy
 
You might also want to incorporate a 'timeout' so that if they make a typo they can try again after a second or two.
Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
    Static Timeout As Double
    If (Timeout <> 0) Then
        if (Timer > Timeout) Then Str = ""
    End If
    Timeout = Timer + 2
    str = str & Chr(KeyAscii)

    If str = "vinner" Then
        MsgBox "You have opened an easter egg."
    End If
End Sub

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 

or:
Code:
Private Sub Form_MouseMove(Button As Integer, _
    Shift As Integer, X As Single, Y As Single)
str = ""
End Sub
whipe it clean with the mouse move

Have fun.

---- Andy
 
Thanks Andy.

Yes I had fun with it.
I used your suggestion with the mousemove event in case of spelling error. But instead of a msgBox being shown, as "vinner" is typed, a new form is loaded. The "vinner" form is then unloaded with another mousemove event.
Thanks you very much!
A star goes to you.

Christian
 
Sorry, I ment: Thank Andrzejek, whom also got the star becouse I used his suggestion.
 
[unsheathing ritual suicide sword...]

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 

Don't do it! You have so much to live for.... :)

Have fun.

---- Andy
 
But also thanks to you, AndyGroom, for your suggestion, sorry I didn't mention it earlier. I innitially though you both were the same Andy (didn't read carefully the name, saw only that it was from, in both instances an Andy :-( ). Again sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top