Results 1 to 12 of 12

Thread: Problems with KeyDown

  1. #1

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    For some reason I cannot get VB to register when the Tab key is pressed. Any idea why?

    ------------------
    Ryan

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    It should. Are you checking for vbKeyTab (=9)?

    ------------------
    Marty
    What did the fish say when it hit the concrete wall?
    > > > > > "Dam!"

  3. #3

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    yes, I am, but see the thing is, it's not even going into the KeyDown event code. So it's not even getting to the

    If KeyCode = vbKeyTab Then

    statement. And I can't figure out why.

    ------------------
    Ryan


    [This message has been edited by Gimpster (edited 02-10-2000).]

  4. #4
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    That should work. Are you sure you put this code in KeyDown / KeyUp and not KeyPress?

    ------------------
    [email protected]
    ...
    Every program can be reduced to one instruction which doesn't work.


  5. #5

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    yes, I'm sure. I mean it's very baffling, because I have a break point set at the very first line of the KeyDown event and VB doesn't even go into the event code. It never even looks there. It just goes on and inserts the tab and that's it. It doesn't check any code whatsoever. I don't understand it.

    ------------------
    Ryan

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Do you have code in the LostFocus event? If so that will fire first.

    ------------------
    Marty
    What did the fish say when it hit the concrete wall?
    > > > > > "Dam!"

  7. #7

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    Yes, I do. The code I have in the LostFocus event re-enables all the tabstops on the other objects. That's the only thing it does, but would that cause problems?

    ------------------
    Ryan

  8. #8
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Apparently it does. I created a small app with two textboxes and 1 command button. I set Text2.TabStop = False and in Text1.LostFocus I set Text2.TabStop = True. I also set a breakpoint in Text1.KeyDown. When I ran the program and tabbed out of Text1, the KeyDown event never happened.

    ------------------
    Marty
    What did the fish say when it hit the concrete wall?
    > > > > > "Dam!"

  9. #9
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    I would say that the problem is deeper!
    TAB is (i think) sending a system message to change the focus to the next control, and thiat is happening even befor the form is envoking any events (including controls events)

  10. #10
    New Member
    Join Date
    Feb 2000
    Posts
    12

    Post

    Hey!! Whats going on...

    You may want to try setting the KeyPreview property of you FORM to true, and put the check for the TAB key in the KEY DOWN event of the form.

    I had a similar problem trying to get DELETE and BACKSPACE to work together. this did the trick!

    Hope it helps!

    ~Sam

  11. #11
    Hyperactive Member razzaj's Avatar
    Join Date
    Oct 1999
    Location
    jounieh
    Posts
    261

    Post

    Gimpster ;
    Vb is slow at getting keydowns events ,
    when u press tab over a form or any control
    give it some time ... press it for a while
    2 to 5 seconds ... i had the same problem when holding a shift key over a button ,
    i have to hold the shift key over the button for a while for vb to notice this ...
    try it , i think it will work ...


    ------------------
    - regards -
    - razzaj -

  12. #12

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    Ok, thank you for all the suggestions. And, Rassaj, do you know if there is any way to make VB recognize the keydown quicker?

    ------------------
    Ryan

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