Custom Search
Your Ad Here
Latest News

This following code just allowed you to entered strings / alphabetics only (no numbers or any special characters):

10/27/08 , Posted by Gregfox at 6:15 AM

  1. Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
  2. If (Microsoft.VisualBasic.Asc(e.KeyChar) < 65) _
  3. Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 90) _
  4. And (Microsoft.VisualBasic.Asc(e.KeyChar) < 97) _
  5. Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 122) Then
  6. 'Allowed space
  7. If (Microsoft.VisualBasic.Asc(e.KeyChar) <> 32) Then
  8. e.Handled = True
  9. End If
  10. End If
  11. ' Allowed backspace
  12. If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
  13. e.Handled = False
  14. End If
  15. End Sub

Currently have 0 comments:

Leave a Reply

Post a Comment