Wednesday, April 29, 2009

Detect Key You Press

'Detect Key You Press

Private Declare Function IsCharAlpha Lib "user32" Alias _

"IsCharAlphaA" (ByVal cChar As Byte) As Long

Private Declare Function IsCharAlphaNumeric Lib "user32" _

Alias "IsCharAlphaNumericA" (ByVal cChar As Byte) As Long

Private Declare Function IsCharLower Lib "user32" Alias _

"IsCharLowerA" (ByVal cChar As Byte) As Long

Private Declare Function IsCharUpper Lib "user32" Alias _

"IsCharUpperA" (ByVal cChar As Byte) As Long



Private Sub Form_KeyPress(KeyAscii
As Integer)

Dim strSave As String

'Clear the form

Me.Cls

'Set the current Y-position to 0

Me.CurrentY = 0

'Get the character information

If IsCharAlphaNumeric(KeyAscii) Then strSave = " AlphaNumeric"

If IsCharAlpha(KeyAscii) Then strSave = "Alpha"

If IsCharLower(KeyAscii) Then strSave = strSave + " Lower"

If IsCharUpper(KeyAscii) Then strSave = strSave + " Upper"

'Print the information to the form

Me.Print "You pressed: " + Chr$(KeyAscii)

Me.Print "This is:" + strSave

End Sub



Private Sub Form_Load()

   
Form1.Caption = "Press Any Key"

End Sub

 

No comments:

Post a Comment