Override the ProcessCmdKey function on the form as below:
Protected Overrides Function ProcessCmdKey(ByRef msg As
System.Windows.Forms.Message, _
ByVal keyData As System.Windows.Forms.Keys) As Boolean
Select Case CType(msg.WParam.ToInt32, Keys)
Case Keys.Enter
MsgBox("enter")
Return True
Case Keys.Back
MsgBox("Backspace")
Return True
Case Else
Return MyBase.ProcessCmdKey(msg, keyData)
End Select
End Function
the "Return True" indicates you've processed that key and don't want the
base class (the form) to process it.
This way you can block virtually any type of key stroke (well, atleast those
that are defined in the 'Keys' enum).
hope this helps..
Imran.
"Phil Galey" <pa*****@starcalif.com.nospam> wrote in message
news:Ou*************@TK2MSFTNGP12.phx.gbl...
In VB6 you can block invalid keystrokes in the KeyPress event by setting
KeyAscii = 0.
How can you block invalid keystrokes in VB.NET?