command button got focus

need help with got focus and key commands

Page 1 of 1

2 Replies - 5760 Views - Last Post: 07 February 2010 - 10:43 PM Rate Topic: -----

#1 justme187  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-February 10

command button got focus

Posted 04 February 2010 - 02:10 PM

hi, i'm using vb6..
i have a simple problem. all i want to do is to be able to "click" on a button that has focus by hitting the enter key..

i have several command buttons that i can select with the arrow keys but i want to be able to hit ENTER instead of using the mouse..thank you... :D
Is This A Good Question/Topic? 0
  • +

Replies To: command button got focus

#2 rainbow evil  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 308
  • Joined: 15-July 09

Re: command button got focus

Posted 04 February 2010 - 03:32 PM

I am confused... Pressing the enter key on a command button that has focus does press it. When the button supposedly has focus, does it have the dotted lines around the edge? If not, it probably does not actually have focus. It would be more useful if you posted an excerpt of your arrow key pressing codes to see whether they are the problem as to why this isn't working for you.
Was This Post Helpful? 0
  • +
  • -

#3 Kinwang2009  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 76
  • Joined: 07-February 10

Re: command button got focus

Posted 07 February 2010 - 10:43 PM

Hi justme,

I understand your problem. Use the below code.

Private Sub cmdOK_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then frmMain.Show
End Sub

The above code will display frmMain when you hit ENTER on keyboard while cmdOK is on setfocus.

Hope this helps.

Thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1