Results 1 to 7 of 7

Thread: Disable keys

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    Disable keys

    Hi,

    i currently have a program, it will run full screen so it cannot be closed without the use of a button, i want something that will disable ALL keys apart from the few keys i want to be enabled, is there a way to do this and if so how?

    as an example if possible lets say the letters A,B,C, will be all unblocked.

    thanks
    lee
    If a post has been usefull then Rate it!

  2. #2
    Hyperactive Member Private_sub's Avatar
    Join Date
    Nov 2005
    Location
    +31
    Posts
    368

    Re: Disable keys

    you could make a list of all keys, and use "for each" to filter A, B and C out.
    and just search the forum for the code to disable the keys.

  3. #3
    Member
    Join Date
    Dec 2005
    Posts
    63

    Re: Disable keys

    In the Form_KeyPress event, put code similar to the following:
    VB Code:
    1. If KeyAscii = 97 Then
    2.         'A Key was pressed, so do something
    3.     ElseIf KeyAscii = 98 Then
    4.         'B Key was pressed, do something else
    5.     ElseIf KeyAscii = 99 Then
    6.         'C Key was pressed, do yet another thing
    7.     Else
    8.         KeyAscii = 0
    9.     End If



  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    Re: Disable keys

    Thanks mark thats very useful
    If a post has been usefull then Rate it!

  5. #5
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: Disable keys

    To make MarkDorf's code more readable use VB's built in constants
    VB Code:
    1. If KeyAscii = vbKeyA Then
    2.     'A Key was pressed, so do something
    3. ElseIf KeyAscii = vbKeyB Then
    4.     'B Key was pressed, do something else
    5. ElseIf KeyAscii =  vbKeyC Then
    6.     'C Key was pressed, do yet another thing
    7. Else
    8.     KeyAscii = 0
    9. End If
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  6. #6

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    419

    Re: Disable keys

    thanks (yeah i already had an ascii table but this one it much easier thanks)
    If a post has been usefull then Rate it!

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