Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Enter out of a Text Box


Message #1 by "Williams, Sean" <swilliams@g...> on Wed, 30 Oct 2002 22:01:40 -0000
Microsoft advises AGAINST using SendKeys in some circumstances. See KB 
article 276346 "SendKeys Function Locks Keyboard on Windows 2000".

Try this. Put the following in the Declarations part of your form:

'=============================================================
' API function for "converting" the <Enter> key to a <Tab> key
'=============================================================
Private Const VK_TAB = &H9
Private Declare Sub keybd_event Lib "user32" _
                                     (ByVal bVk As Byte, _
                                      ByVal bScan As Byte, _
                                      ByVal dwFlags As Long, _
                                      ByVal dwExtraInfo As Long)

'=============================================================

In you code put this in the KeyPress() event:


     If KeyAscii = vbKeyReturn Then
         KeyAscii = 0
         keybd_event VK_TAB, 0, 0, 0
     End If

Regards,
-Toby


>From: Williams, Sean [mailto:swilliams@g...]
>Sent: Wednesday, October 30, 2002 4:02 PM
>To: professional vb
>Subject: [pro_vb] Enter out of a Text Box
>
>This must be simple....
>
>How can you ENTER out of a text box ?
>
>I can Tab out,   but how do you ENTER out ?   I know it sounds weird
>perhaps  RETURN might sound better.


  Return to Index