QUOTE(Jayman @ 7 Jan, 2009 - 08:30 AM)

You need to compare the Key to the KeyCode. I am not sure why you are trying to convert the Key to a Boolean.
It should also be noted that the Form must have focus in order to capture the keypress. If another control on your form has focus then this event will not execute, since it is specific to the form.
CODE
Private Sub Form1_KeyPress(ByVal as Object, ByVal e as Systems.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If e.KeyCode = Keys.Escape Then
e.Handled = True
End If
End Sub
Thanks both for the code. Unfortunately the Escape key remains live. Ideally I what to run the code in the form Load event. With Jaman’s Code e.KeyCode returns an error [not a member of KeyPressEventArgs]
Perhaps it’s worth stating the reason; I have a start up form which has been customised with a Log In textbox password which is set in the start up form properties. To achieve a smooth display of the main form I have called it in the Start Up form load event, which works ok.
Except that if Alt+Esc is press the start up form is closed and the main form display, thereby bypassing the password. I have tried displaying modally without success.
hemo