PC Review


Reply
Thread Tools Rate Thread

Distinguish between '<' and '.' with KeyUp?

 
 
robotman
Guest
Posts: n/a
 
      12th Jun 2007
I'm trying to capture key presses in a text control on a form and need
to use KeyUp event (vs. Keypress) so I can capture the arrow keys.

It doesn't appear that KeyUp distinguishes between '<' and ',' (since
they are both the same key on the keyboard).

Am I missing something? Is there some event that captures arrow keys
AND would distinguish between '<' and ','?

Thanks.

John

 
Reply With Quote
 
 
 
 
Vasant Nanavati
Guest
Posts: n/a
 
      12th Jun 2007
Maybe I'm missing something (I'm a bit rusty), but this works for me in
Excel XP:

Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
Select Case KeyCode
Case 37
MsgBox "Left"
Case 38
MsgBox "Up"
Case 39
MsgBox "Right"
Case 40
MsgBox "Down"
Case 188
If Shift = 0 Then
MsgBox "Comma"
Else
MsgBox "Less than"
End If
Case Else
End Select
End Sub

_________________________________________________________________________



"robotman" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to capture key presses in a text control on a form and need
> to use KeyUp event (vs. Keypress) so I can capture the arrow keys.
>
> It doesn't appear that KeyUp distinguishes between '<' and ',' (since
> they are both the same key on the keyboard).
>
> Am I missing something? Is there some event that captures arrow keys
> AND would distinguish between '<' and ','?
>
> Thanks.
>
> John
>



 
Reply With Quote
 
robotman
Guest
Posts: n/a
 
      12th Jun 2007
One piece of information that I didn't mention is that the characters
are actually coming from a piece of equipment through a keyboard wedge
so there aren't any physical keys being pressed.

I was assuming that the KeyUp wouldn't intrepet the "Shift" correctly
(since it wasn't actually being pressed), but your code does work. I
guess the event looks first at the ASCII it has received and then
assigns the SHIFT value and assigns the keycode based on the ASCII.

It's interesting that when it receives a "<" from the instrument, it
triggers the event twice... once for the ',' and then again for the
virtual shift release.

Thanks for your help.

John

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
KeyUp events Ben Microsoft C# .NET 11 25th Jun 2007 10:43 AM
On KeyUp problem Sam Microsoft Access ADP SQL Server 0 30th Nov 2005 03:34 PM
DataGridTextBoxColumn KeyUp =?Utf-8?B?a2VubmV0aEBub3NwYW0ubm9zcGFt?= Microsoft Dot NET Framework 1 14th Jun 2005 10:35 AM
KeyUp event Rick A Microsoft C# .NET 0 21st Oct 2004 10:00 PM
KeyUp in MsgBox Amaro Cantador Microsoft Dot NET 0 18th Sep 2004 03:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:28 AM.