Go Back   Forum Care Forums > Development Reference Area > Visual Basic

Reply
 
LinkBack Thread Tools Display Modes
vbkey codes??
Old
  (#1)
H
Guest
 
Posts: n/a
Default vbkey codes?? - 06-04-2007, 09:49 AM

Anyone know the code for " ` " (left quote?).. Its the key in the top left
hand corner under the escape key.... (UK keyboard, others might be
different?)

Found all the ordinary ones, but havent a clue for this one! Found a site
that says its 96? How do I ***ign this?

Sorry for this post, im new to trapping keyboard events..

Ta!


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Re: vbkey codes??
Old
  (#2)
mayayana
Guest
 
Posts: n/a
Default Re: vbkey codes?? - 06-04-2007, 09:49 AM

There are occasional variations in KeyCodes
with different countries. I'm not sure about ASCII.
For the accent character it's ASCII 96, which is
connected with KeyPress. The KeyCode is 192,
connected with key up and key down.
You can check any of them easily. Just start a project,
add a text box, and add this code:

Private Sub Text1_KeyPress(KeyAscii As Integer)
Debug.Print "Ascii: " & CStr(KeyAscii)
End Sub

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Debug.Print "Keycode: " & CStr(KeyCode)
End Sub

That will print the numbers in the debug window as you type
in the textbox.

> Anyone know the code for " ` " (left quote?).. Its the key in the top

left
> hand corner under the escape key.... (UK keyboard, others might be
> different?)
>
> Found all the ordinary ones, but havent a clue for this one! Found a site
> that says its 96? How do I ***ign this?
>
> Sorry for this post, im new to trapping keyboard events..
>
> Ta!
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: vbkey codes??
Old
  (#3)
Randy Birch
Guest
 
Posts: n/a
Default Re: vbkey codes?? - 06-04-2007, 09:49 AM

in the keypress and/or keydown event on a form with keypreview set to true,
add:

debug.print keycode

or

debug.print keyasii

... as appropriate to view the key codes pressed.

--

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.


"H" <EMAIL REMOVED> wrote in message
news:0iSdnUMjUJ_-EMAIL REMOVED...
: Anyone know the code for " ` " (left quote?).. Its the key in the top
left
: hand corner under the escape key.... (UK keyboard, others might be
: different?)
:
: Found all the ordinary ones, but havent a clue for this one! Found a site
: that says its 96? How do I ***ign this?
:
: Sorry for this post, im new to trapping keyboard events..
:
: Ta!
:
:
: ---
: Outgoing mail is certified Virus Free.
: Checked by AVG anti-virus system (http://www.grisoft.com).
: Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
:
:

   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: vbkey codes??
Old
  (#4)
H
Guest
 
Posts: n/a
Default Re: vbkey codes?? - 06-04-2007, 09:49 AM

Thanks guys, but how to I implement this? Heres a bit of code..

Select Case KeyCode
Case vbKeyC
x = MsgBox("You pressed C") ' Works
Case 192
x = MsgBox("You pressed ' ") ' dont work
End Select

When I use the code below to find keycodes, nothing appears..

Debug.Print "Keycode: " & CStr(KeyCode)

Except for "Keycode".

Sorry for being a pain.

"Randy Birch" <EMAIL REMOVED> wrote in message
news:zRtYc.38$EMAIL REMOVED gers.com...
> in the keypress and/or keydown event on a form with keypreview set to
> true,
> add:
>
> debug.print keycode
>
> or
>
> debug.print keyasii
>
> .. as appropriate to view the key codes pressed.
>
> --
>
> Randy Birch
> MVP Visual Basic
> http://vbnet.mvps.org/
> Please respond only to the newsgroups so all can benefit.
>
>
> "H" <EMAIL REMOVED> wrote in message
> news:0iSdnUMjUJ_-EMAIL REMOVED...
> : Anyone know the code for " ` " (left quote?).. Its the key in the top
> left
> : hand corner under the escape key.... (UK keyboard, others might be
> : different?)
> :
> : Found all the ordinary ones, but havent a clue for this one! Found a
> site
> : that says its 96? How do I ***ign this?
> :
> : Sorry for this post, im new to trapping keyboard events..
> :
> : Ta!
> :
> :
> : ---
> : Outgoing mail is certified Virus Free.
> : Checked by AVG anti-virus system (http://www.grisoft.com).
> : Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
> :
> :
>



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: vbkey codes??
Old
  (#5)
mayayana
Guest
 
Posts: n/a
Default Re: vbkey codes?? - 06-04-2007, 09:49 AM

"KeyCode" in that case is a parameter of the
textbox KeyUp event. It works in the textbox KeyUp
sub. You sample doesn't indicate where you're
trying to use it, but presumably you're trying to catch
the keycode for text entered into a specific control,
like a textbox. So you need to catch it there.

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)


--
--
H <EMAIL REMOVED> wrote in message
news:EMAIL REMOVED...
> Thanks guys, but how to I implement this? Heres a bit of code..
>
> Select Case KeyCode
> Case vbKeyC
> x = MsgBox("You pressed C") ' Works
> Case 192
> x = MsgBox("You pressed ' ") ' dont work
> End Select
>
> When I use the code below to find keycodes, nothing appears..
>
> Debug.Print "Keycode: " & CStr(KeyCode)
>
> Except for "Keycode".
>
> Sorry for being a pain.
>
> "Randy Birch" <EMAIL REMOVED> wrote in message
> news:zRtYc.38$EMAIL REMOVED gers.com...
> > in the keypress and/or keydown event on a form with keypreview set to
> > true,
> > add:
> >
> > debug.print keycode
> >
> > or
> >
> > debug.print keyasii
> >
> > .. as appropriate to view the key codes pressed.
> >
> > --
> >
> > Randy Birch
> > MVP Visual Basic
> > http://vbnet.mvps.org/
> > Please respond only to the newsgroups so all can benefit.
> >
> >
> > "H" <EMAIL REMOVED> wrote in message
> > news:0iSdnUMjUJ_-EMAIL REMOVED...
> > : Anyone know the code for " ` " (left quote?).. Its the key in the top
> > left
> > : hand corner under the escape key.... (UK keyboard, others might be
> > : different?)
> > :
> > : Found all the ordinary ones, but havent a clue for this one! Found a
> > site
> > : that says its 96? How do I ***ign this?
> > :
> > : Sorry for this post, im new to trapping keyboard events..
> > :
> > : Ta!
> > :
> > :
> > : ---
> > : Outgoing mail is certified Virus Free.
> > : Checked by AVG anti-virus system (http://www.grisoft.com).
> > : Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
> > :
> > :
> >

>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: vbkey codes??
Old
  (#6)
H
Guest
 
Posts: n/a
Default Re: vbkey codes?? - 06-04-2007, 09:49 AM


"mayayana" <EMAIL REMOVED> wrote in message
news:jmFYc.8092$EMAIL REMOVED nk.net...
> "KeyCode" in that case is a parameter of the
> textbox KeyUp event. It works in the textbox KeyUp
> sub. You sample doesn't indicate where you're
> trying to use it, but presumably you're trying to catch
> the keycode for text entered into a specific control,
> like a textbox. So you need to catch it there.
>
> Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
>


Hi, its used on a form in Keydown.. Ive already set KeyPreview to true
and all of the actual vbkeys work, just dosent want to let me put a number
in there instead!

I'll go spend some more time nutting the wall!

Thanks.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: vbkey codes??
Old
  (#7)
preben nielsen
Guest
 
Posts: n/a
Default Re: vbkey codes?? - 06-04-2007, 09:49 AM


"H" <EMAIL REMOVED> skrev i en meddelelse
news:0iSdnUMjUJ_-EMAIL REMOVED...
> Anyone know the code for " ` " (left quote?).. Its the key in

the top left
> hand corner under the escape key.... (UK keyboard, others might

be
> different?)
>
> Found all the ordinary ones, but havent a clue for this one!

Found a site
> that says its 96? How do I ***ign this?


Debug.Print Asc("`")



--
/\ preben nielsen
\/\ EMAIL REMOVED


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: vbkey codes??
Old
  (#8)
mayayana
Guest
 
Posts: n/a
Default Re: vbkey codes?? - 06-04-2007, 09:49 AM

I just tried it and it worked fine in the Form_KeyDown sub.
If I use debug.print cstr(keycode) in that sub I get 192.
If you want to trap specific keys you can do it with
Select Case. You can then check Shift to find whether the accent
character or the tilde was typed.

Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Shift = 0 then '-- Shift key not pressed
Select Case Keycode
Case 192 '-- accent
msgbox "Accent character."
Case 190 '-- period
msgbox "Period was typed."
Case 32 '-- space
msgbox "Space was typed."
...etc.......
End Select
End If
End Sub
--
--
H <EMAIL REMOVED> wrote in message
news:EMAIL REMOVED...
>
> "mayayana" <EMAIL REMOVED> wrote in message
> news:jmFYc.8092$EMAIL REMOVED nk.net...
> > "KeyCode" in that case is a parameter of the
> > textbox KeyUp event. It works in the textbox KeyUp
> > sub. You sample doesn't indicate where you're
> > trying to use it, but presumably you're trying to catch
> > the keycode for text entered into a specific control,
> > like a textbox. So you need to catch it there.
> >
> > Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
> >

>
> Hi, its used on a form in Keydown.. Ive already set KeyPreview to true
> and all of the actual vbkeys work, just dosent want to let me put a number
> in there instead!
>
> I'll go spend some more time nutting the wall!
>
> Thanks.
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
>
>



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: vbkey codes??
Old
  (#9)
H
Guest
 
Posts: n/a
Default Re: vbkey codes?? - 06-04-2007, 09:49 AM

Thankyou, Ive got it now! On my keyboard (UK) the code is 223.. But
im also going to include 192 for compatibility with others.

Thanks so much for you time guys.

Hellen.

"mayayana" <EMAIL REMOVED> wrote in message
news:KGOYc.8740$EMAIL REMOVED ink.net...
>I just tried it and it worked fine in the Form_KeyDown sub.
> If I use debug.print cstr(keycode) in that sub I get 192.
> If you want to trap specific keys you can do it with
> Select Case. You can then check Shift to find whether the accent
> character or the tilde was typed.
>
> Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
> If Shift = 0 then '-- Shift key not pressed
> Select Case Keycode
> Case 192 '-- accent
> msgbox "Accent character."
> Case 190 '-- period
> msgbox "Period was typed."
> Case 32 '-- space
> msgbox "Space was typed."
> ...etc.......
> End Select
> End If
> End Sub
> --
> --
> H <EMAIL REMOVED> wrote in message
> news:EMAIL REMOVED...
>>
>> "mayayana" <EMAIL REMOVED> wrote in message
>> news:jmFYc.8092$EMAIL REMOVED nk.net...
>> > "KeyCode" in that case is a parameter of the
>> > textbox KeyUp event. It works in the textbox KeyUp
>> > sub. You sample doesn't indicate where you're
>> > trying to use it, but presumably you're trying to catch
>> > the keycode for text entered into a specific control,
>> > like a textbox. So you need to catch it there.
>> >
>> > Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
>> >

>>
>> Hi, its used on a form in Keydown.. Ive already set KeyPreview to true
>> and all of the actual vbkeys work, just dosent want to let me put a
>> number
>> in there instead!
>>
>> I'll go spend some more time nutting the wall!
>>
>> Thanks.
>>
>>
>> ---
>> Outgoing mail is certified Virus Free.
>> Checked by AVG anti-virus system (http://www.grisoft.com).
>> Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004
>>
>>

>
>



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.742 / Virus Database: 495 - Release Date: 19/08/2004


   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Re: vbkey codes??
Old
  (#10)
mayayana
Guest
 
Posts: n/a
Default Re: vbkey codes?? - 06-04-2007, 09:49 AM


> Thankyou, Ive got it now! On my keyboard (UK) the code is 223.. But
> im also going to include 192 for compatibility with others.


In that case you might also want to check other
keys that you're using. (I have an editor program
that traps the period character and occasionally
get emails from Europeans. It seems that on some
keyboards the US period (190) is the semi-colon.)

I looked up in MSDN and found a list of VB
keycode constants. You can also find them under
"VBRUN" "global" in the object browser, but the
punctuation keys don't seem to be in either list.



   
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

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 On





Contact Us - Forum Care Forums - Archive - Top