title: How to use ASCII code for Enter in vb.net
body: <p>I am having a little problem getting my code to do what I want.</p>
  
  <p>I want to prevent the user from using the Enter button when he/she is entering text into a text. The code I am using is:</p>
  
  <pre><code> Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
      If Asc(e.KeyChar) = 13 Then
          e.Handled = False
      Else
          e.Handled = True
          MsgBox("Error.")
      End If
  End Sub
  </code></pre>
  
  <p>This not achieving my objective. Please how can I re-write this?</p>