Blog : Verify that the textbox1 is only allowed string input.

verify that the textbox1 is only allowed string input.

I had a submit button,when i click the button,it will verify that the textbox1 is only allowed string input.How can I do so??
 A TextBox will only take String type data, so I'm not 100% sure what you mean.

Is it that you want ot restrict users to entering just letters of the alphabet or something like that?
Yes,I just want the user to enter alphabet only(Eg.a-z,A-Z)...
Dim regX As New Regex("[A-Za-z]+$")


If Not (regX.IsMatch(YourStringHere)) Then
 'not Alphabet
Else
  'alphabet
End If
Private Sub MaskedTextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MaskedTextBox1.KeyPress
  If Char.IsLetter(e.KeyChar) Then
  e.Handled = False
  Else
  e.Handled = True
  End If
  End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
   
  e.Handled = True 'This effectively Cancels the Keypress
   
  If e.KeyChar Like "[A-z]" Or _
  e.KeyChar = Chr(&H8) Then
  e.Handled = False
'Resume keypress if condition is true
  End Sub
If Char.IsControl(e.KeyChar) Then

If Not IsNumeric(e.KeyChar) Then
  'String or control
  Else
  'Integer
  End If