Code Comments
Programming Forum and web based access to our favorite programming groups.Hi, Do you have any idea why a form keypress event would stop to catch the "enter" key? Even if I run this: Private Sub Form_KeyPress(KeyAscii As Integer) msgbox KeyAscii End Sub The "enter" key is not catched..... In my form I don't have any control who could disable the enter key event. Any suggestion would be appreciated. Marty
Post Follow-up to this message"Marty" <reply@to.forum> wrote in message news:FeC6d.2433$eq.843@edtnps84 > Hi, > > Do you have any idea why a form keypress event would stop to catch the > "enter" key? > > Even if I run this: > > Private Sub Form_KeyPress(KeyAscii As Integer) > msgbox KeyAscii > End Sub > > The "enter" key is not catched..... > > In my form I don't have any control who could disable the enter key > event. Do you have a command button with .Default=True ? -- Reply to the group so all can participate VB.Net... just say "No"
Post Follow-up to this message> > Do you have a command button with .Default=True ? > No, I don't.
Post Follow-up to this messageThe KeyPress event seems to favor controls. I just use the KeyPress event o f the control I know will have the focus. "Marty" wrote: > > > No, I don't. >
Post Follow-up to this message> "enter" key? > > Even if I run this: > > Private Sub Form_KeyPress(KeyAscii As Integer) > msgbox KeyAscii > End Sub > > The "enter" key is not catched..... > > In my form I don't have any control who could disable the enter key event. Do you have the form's KeyPreview property set to True? If not, try setting it to that. Rick - MVP
Post Follow-up to this message"Marty" <reply@to.forum> wrote in message news:XtC6d.2436$eq.1382@edtnps84 > > No, I don't. The form's KeyPreview property is True? do the KeyDown and/or KeyUp events fire? what control types are on the form? -- Reply to the group so all can participate VB.Net... just say "No"
Post Follow-up to this messageYes the form' KeyPreview = True I did another test. sub Form_load() btnMyEvent.Default = True 'Command button control btnMyEvent.getFocus = True end sub Private Sub btnMyEvent_KeyPress(KeyAscii As Integer) MsgBox KeyAscii End Sub This won't catch the "enter" key. All other key are catched...
Post Follow-up to this message"Marty" <reply@to.forum> wrote in message news:rMC6d.2449$eq.443@edtnps84 > Yes the form' KeyPreview = True > > I did another test. > > sub Form_load() > btnMyEvent.Default = True 'Command button control > btnMyEvent.getFocus = True there is no .GetFocus property on command buttons in VB... are you using VB.Net or VB 2005 and confusing it with VB6 and/or earlier versions? If so, you are asking in the wrong newsgroup and need to find one with 'dotnet' in the name. -- Reply to the group so all can participate VB.Net... just say "No"
Post Follow-up to this messageMy mistake, I mean : btnMyEvent.SetFocus instead of btnMyEvent.GetFocus Bob Butler wrote: > "Marty" <reply@to.forum> wrote in message > news:rMC6d.2449$eq.443@edtnps84 > > > > there is no .GetFocus property on command buttons in VB... are you using > VB.Net or VB 2005 and confusing it with VB6 and/or earlier versions? If s o, > you are asking in the wrong newsgroup and need to find one with 'dotnet' i n > the name. >
Post Follow-up to this message"Marty" <reply@to.forum> wrote in message news:cYC6d.2452$eq.10@edtnps84 > My mistake, > > I mean : > btnMyEvent.SetFocus > > instead of > btnMyEvent.GetFocus No problem; I just tried it and apparently when a command button has the focus the KeyXXXX events are not fired for ENTER. It also doesn't fire the default command button unless that's the one that has the focus. I don't remember running into that before. -- Reply to the group so all can participate VB.Net... just say "No"
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.