title: Unable to detect KeyPress event for Enter key
body: <p>I am trying to use the KeyPress event in VB.NET 2008, but it is not working.  Can anyone help me figure out what is wrong with this code?  This message box does not appear and the my status from my DB doesn't either.  The program says that it is OK, but it isn't working.</p>
  
  <pre><code>If e.KeyChar = Chr(Keys.Enter) Then
      tblLogin = Proses.ExecuteQuery("Select * From TblUser where kode_user = '" &amp; KdUserTxt.Text &amp; "'")
      If tblLogin.Rows.Count = 0 Then
          MessageBox.Show("Kode User Not Found!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
          KdUserTxt.Focus()
      Else
          StatusTxt.Text = tblLogin.Rows(0).Item("status")
          PswTxt.Focus()
      End If
  End If
  </code></pre>