title: Disabling alphabetic letters and special characters in Visual Basic.NET
body: <p>Im new to visual basic and im unsure on how to disable alphabetic and special characters. </p>
  
  <p>I Only want the user to be able to input numbers.</p>
  
  <p>Im using this code im know there is an easier way to do it and all help is appreciated</p>
  
  <p>I get the message box when I input alphabetic characters and when I input numbers. i dont want to get the message box when i input numbers.</p>
  
  <pre><code>Private Sub txtCustom_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtCustom.KeyDown
  
      If (e.KeyCode = Keys.Enter) Then
  
          e.SuppressKeyPress = True
  
          If (e.KeyCode = Keys.A Or Keys.B Or Keys.C Or Keys.D Or Keys.E Or Keys.F Or Keys.G Or Keys.H Or Keys.I Or Keys.J Or Keys.K Or Keys.L Or Keys.M Or Keys.N Or Keys.O Or Keys.P Or Keys.Q Or Keys.R Or Keys.S Or Keys.T Or Keys.U Or Keys.V Or Keys.W Or Keys.X Or Keys.Y Or Keys.Z) Then
  
              Beep()
              MsgBox("Please Input A Numerical Value")
              txtCustom.Text = ""
  
          Else
  
              RandNumAllow = txtCustom.Text
  
          End If
  
      End If
  
  End Sub
  </code></pre>