vbkey codes??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • H

    #1

    vbkey codes??

    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 assign 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


  • mayayana

    #2
    Re: vbkey codes??

    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(Key Code 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.
    [color=blue]
    > Anyone know the code for " ` " (left quote?).. Its the key in the top[/color]
    left[color=blue]
    > 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 assign 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
    >
    >[/color]


    Comment

    • Randy Birch

      #3
      Re: vbkey codes??

      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

      Please respond only to the newsgroups so all can benefit.


      "H" <H@opijpoijpoij .com> wrote in message
      news:0iSdnUMjUJ _-1K_cSa8jmw@karo o.co.uk...
      : 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 assign 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
      :
      :

      Comment

      • H

        #4
        Re: vbkey codes??

        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" <rgb_removethis @mvps.org> wrote in message
        news:zRtYc.38$W Gw1.27@news04.b loor.is.net.cab le.rogers.com.. .[color=blue]
        > 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" <H@opijpoijpoij .com> wrote in message
        > news:0iSdnUMjUJ _-1K_cSa8jmw@karo o.co.uk...
        > : 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 assign 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
        > :
        > :
        >[/color]


        ---
        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


        Comment

        • mayayana

          #5
          Re: vbkey codes??

          "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(Key Code As Integer, Shift As Integer)


          --
          --
          H <H@opijpoijpoij .com> wrote in message
          news:F9KdnahfRv 8iQa_cSa8jmw@ka roo.co.uk...[color=blue]
          > 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" <rgb_removethis @mvps.org> wrote in message
          > news:zRtYc.38$W Gw1.27@news04.b loor.is.net.cab le.rogers.com.. .[color=green]
          > > 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" <H@opijpoijpoij .com> wrote in message
          > > news:0iSdnUMjUJ _-1K_cSa8jmw@karo o.co.uk...
          > > : 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 assign 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
          > > :
          > > :
          > >[/color]
          >
          >
          > ---
          > 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
          >
          >[/color]


          Comment

          • H

            #6
            Re: vbkey codes??


            "mayayana" <mayaXXyana1a@m indYYspring.com > wrote in message
            news:jmFYc.8092 $6o3.918@newsre ad2.news.atl.ea rthlink.net...[color=blue]
            > "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(Key Code As Integer, Shift As Integer)
            >[/color]

            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


            Comment

            • preben nielsen

              #7
              Re: vbkey codes??


              "H" <H@opijpoijpoij .com> skrev i en meddelelse
              news:0iSdnUMjUJ _-1K_cSa8jmw@karo o.co.uk...[color=blue]
              > Anyone know the code for " ` " (left quote?).. Its the key in[/color]
              the top left[color=blue]
              > hand corner under the escape key.... (UK keyboard, others might[/color]
              be[color=blue]
              > different?)
              >
              > Found all the ordinary ones, but havent a clue for this one![/color]
              Found a site[color=blue]
              > that says its 96? How do I assign this?[/color]

              Debug.Print Asc("`")

              :)

              --
              /\ preben nielsen
              \/\ prel@post.tele. dk


              Comment

              • mayayana

                #8
                Re: vbkey codes??

                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(Ke yCode 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 <H@opijpoijpoij .com> wrote in message
                news:sL2cnVPRvv 0L2K7cSa8jmw@ka roo.co.uk...[color=blue]
                >
                > "mayayana" <mayaXXyana1a@m indYYspring.com > wrote in message
                > news:jmFYc.8092 $6o3.918@newsre ad2.news.atl.ea rthlink.net...[color=green]
                > > "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(Key Code As Integer, Shift As Integer)
                > >[/color]
                >
                > 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
                >
                >[/color]


                Comment

                • H

                  #9
                  Re: vbkey codes??

                  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" <mayaXXyana1a@m indYYspring.com > wrote in message
                  news:KGOYc.8740 $6o3.1791@newsr ead2.news.atl.e arthlink.net...[color=blue]
                  >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(Ke yCode 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 <H@opijpoijpoij .com> wrote in message
                  > news:sL2cnVPRvv 0L2K7cSa8jmw@ka roo.co.uk...[color=green]
                  >>
                  >> "mayayana" <mayaXXyana1a@m indYYspring.com > wrote in message
                  >> news:jmFYc.8092 $6o3.918@newsre ad2.news.atl.ea rthlink.net...[color=darkred]
                  >> > "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(Key Code As Integer, Shift As Integer)
                  >> >[/color]
                  >>
                  >> 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
                  >>
                  >>[/color]
                  >
                  >[/color]


                  ---
                  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


                  Comment

                  • mayayana

                    #10
                    Re: vbkey codes??

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

                    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.



                    Comment

                    Working...