Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KeyCode 13

Status
Not open for further replies.

edderic

Programmer
May 8, 1999
628
KeyCode 13 ("Enter") giving me a beep ,i will not a beep

what is the code to do it ?

PS : not KeyAscii = 0 ,i working with the KeyCode and Not KeyPress (KeyAscii As Integer)

Eric
Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
From VB Help (Keycode Constants)

Constant Value Description
vbKeyReturn 0xD ENTER key
 
That say for me NOTHING !

If you have a little example code ? Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
could you reword your question. i don't understand what you are asking Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
insert keyascii=0 like this.

If KeyAscii = 13 Then
KeyAscii = 0 'to strike out the beep
wKey = ""
For Wi = 1 To wNb
wKey = wKey & "{tab}"
Next Wi

SendKeys wKey
End If
^
good luck
 
Reword the question : it give by the ENTER a BEEP ,i will not a beep !

Source code :

Private Declare Function PeekMessage Lib "user32" Alias _
"PeekMessageA" (lpMsg As MSG, ByVal hwnd As Long, _
ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, _
ByVal wRemoveMsg As Long) As Long

Private Type POINTAPI
x As Long
y As Long
End Type

Private Type MSG
hwnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type

Const PM_NOREMOVE = &H0
Const WM_KEYDOWN = &H100
Const WM_KEYUP = &H101
Const VK_RETURN = &HD

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim MyMsg As MSG, RetVal As Long

' pass:
' MSG structure to receive message information
' my window handle
' low and high filter of 0, 0 to trap all messages
' PM_NOREMOVE to leave the keystroke in the message queue
' use PM_REMOVE (1) to remove it
RetVal = PeekMessage(MyMsg, Me.hwnd, 0, 0, PM_NOREMOVE)

' now, you should look for a MSG.wParam of VK_RETURN
' if this was the keystroke, then test bit 24 of the lparam - if ON,
' then keypad was used, otherwise, keyboard was used
If RetVal <> 0 Then
If MyMsg.wParam = VK_RETURN Then
If MyMsg.lParam And &amp;H1000000 Then
MsgBox &quot;Enter from Keypad pressed&quot;
Else
MsgBox &quot;Enter from Keyboard pressed&quot;
End If
End If
Else
MsgBox &quot;No message waiting, or possible problems calling PeekMessage&quot;
End If
End Sub

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
Eric -

I saw you got your sample code out of the MSDN, and I tried it myself and it beeped for me too. I did change it a bit, though. Instead of the messageboxes, I had it write results to the debug window. And I moved the KeyDown event from the Form to a textbox (Text1). Beep. Beep.

I think what's happening is the textbox is seeing the Enter key before you are, and it beeps. You'll probably have to subclass the textbox in order to get the message before VB does.

Chip H.
 
I haven't subclassed a control in VB. I know you can do it fairly easily with the Desaware SpyWorks package, if you have a copy of that.

Sorry I can't be of more help.

Chip H.
 
Hi Eric

The problem here is the MessageBox! Do you have to use it?

(To check this, change the MsgBox lines to something quick and dirty like &quot;Caption = ...&quot;. No beep now when a key is pressed but the vk message is being received... at least on my system.)

-Ian
 
Ian,

If i do it in a TextBox i have a BEEP

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Dim MyMsg As MSG, RetVal As Long


RetVal = PeekMessage(MyMsg, Me.hwnd, 0, 0, PM_NOREMOVE)

If RetVal <> 0 Then
If MyMsg.wParam = VK_RETURN Then
If MyMsg.lParam And &amp;H1000000 Then
Text2.SetFocus
Else
MsgBox &quot;Enter from Keyboard pressed&quot;
End If
End If
Else
MsgBox &quot;No message waiting, or possible problems calling PeekMessage&quot;
End If

End Sub
Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
Wierd - neither my mod on the form nor your textbox version beep on my PC. I'm using VB6 (SP4) under W2K (SP1). I'll fiddle a bit more.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top