... and if it similar to your preset string of keys, then notice you "right typing", else "wrong typing"
I do searching and changing to have these codes, do you think about any problems with these codes (I hear that if another control belong to this form get focus then these codes are not ok ???)
' Create a lblMsg and btnLogin
Option Explicit
Dim strOfKeys As String
Dim keypresscount As Integer
Private Sub Form_Load()
Me.Show
'The form must handle the key events
Me.KeyPreview = True
strOfKeys = ""
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
' This is to restrict the times of key typing
If keypresscount < 4 Then
strOfKeys = strOfKeys + Chr(KeyAscii)
'MsgBox "Form KeyPress event..." & Chr(KeyAscii) & " Key pressed", vbInformation, "Form Events"
keypresscount = keypresscount + 1
Else
Exit Sub
End If
End Sub
Private Sub btnLogin_Click()
' Suppose that your keys is "abc"
If (strOfKeys = "abc") Then
lblMsg.Caption = "Right typing"
Else
lblMsg.Caption = "Wrong typing"
End If
End Sub
Thanks !!!
:)