Results 1 to 5 of 5

Thread: [2005][Resolved] trouble with keys.oem(number)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    95

    Resolved [2005][Resolved] trouble with keys.oem(number)

    I'm having trouble getting vb to recognize that a number key across the top of the keyboard is being pressed. I think that those keys are Oem1-9.
    this is my code:
    vb Code:
    1. Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
    2.         Select Case e.KeyCode
    3.             Case Is = Keys.A
    4.                 Pic1Move3.Enabled = False
    5.             Case Is = Keys.S
    6.                 Pic1Move2.Enabled = False
    7.             Case Is = Keys.D
    8.                 Pic1Move1.Enabled = False
    9.             Case Is = Keys.W
    10.                 Pic1Move0.Enabled = False
    11.             Case Is = Keys.Up
    12.                 Pic2Move0.Enabled = False
    13.             Case Is = Keys.Right
    14.                 Pic2Move1.Enabled = False
    15.             Case Is = Keys.Down
    16.                 Pic2Move2.Enabled = False
    17.             Case Is = Keys.Left
    18.                 Pic2Move3.Enabled = False
    19.             Case Is = Keys.Oem1
    20.                 Select Case P1Spells(1)
    21.                     Case Is = "Fireball"
    22.                         P1CurrentSpell.BackgroundImage = Image.FromFile("Fireball Icon.png")
    23.                 End Select
    24.             Case Is = Keys.Oem2
    25.                 Select Case P1Spells(2)
    26.                     Case Is = "Fireball"
    27.                         P1CurrentSpell.BackgroundImage = Image.FromFile("Fireball Icon.png")
    28.                 End Select
    29.             Case Is = Keys.Oem3
    30.                 Select Case P1Spells(3)
    31.                     Case Is = "Fireball"
    32.                         P1CurrentSpell.BackgroundImage = Image.FromFile("Fireball Icon.png")
    33.                 End Select
    34.             Case Is = Keys.Oem4
    35.                 Select Case P1Spells(4)
    36.                     Case Is = "Fireball"
    37.                         P1CurrentSpell.BackgroundImage = Image.FromFile("Fireball Icon.png")
    38.                 End Select
    39.             Case Is = Keys.Oem5
    40.                 Select Case P1Spells(5)
    41.                     Case Is = "Fireball"
    42.                         P1CurrentSpell.BackgroundImage = Image.FromFile("Fireball Icon.png")
    43.                 End Select
    44.             Case Is = Keys.Q
    45.                 P1CurrentSpell.BackgroundImage = Nothing
    46.         End Select
    47.     End Sub

    the code works if i use any other key (like the numpad), just not with Oem. It doesnt give me an error, it just does nothing when i press the number keys.
    anyone got a reason why?

    Thanks.
    Last edited by squrrilslayer; Apr 12th, 2008 at 02:48 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] trouble with keys.oem(number)

    If you want to know what they are you simply need to handle the KeyUp event, press one of those keys and test the value of e.KeyCode:
    Code:
    Private Sub Form1_KeyUp(ByVal sender As Object, _
                            ByVal e As KeyEventArgs) Handles Me.KeyUp
        MessageBox.Show(e.KeyCode.ToString())
    End Sub
    When you do that you'll find that you're looking for the wrong values.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    95

    Re: [2005] trouble with keys.oem(number)

    thanks for that tip. Im not home however at the moment, what are the number keys across the top of the keyboard called?
    picture attached with number keys highlighted.
    Attached Images Attached Images  

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] trouble with keys.oem(number)

    D0 to D9. "D" for digit.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    95

    Resolved Re: [2005] trouble with keys.oem(number)

    oh really?!
    i saw that... but.... gah...

    Thanks for the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width