how can i trap my textbox that allows numbers and letters only, no space no special characters e.g (,./;'[]-=`<>?:"{}_+|~!@#$%^&*())

   Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
      If Not Char.IsLetterOrDigit(e.KeyChar) Then
         e.Handled = True
      End If
   End Sub

Just thought about the decimal seperator.

   Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
      If (Not Char.IsLetterOrDigit(e.KeyChar)) And e.KeyChar <> Threading.Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalSeparator Then
         e.Handled = True
      End If
   End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.