Not trying to discredit you, Im just sharing some knowledge. A better way to do something like this (instead of looping through the text each time) would be this.
not allowed
allowed
not allowed
Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim NotAllowed As String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,<>./?; :'{}[]=+-_)(*&^%$#@!~`|\"
If NotAllowed.IndexOf(e.KeyChar) <> -1 Then
e.KeyChar = Nothing
End If
End Sub
allowed
Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim Allowed As String = "abcdefghijklmnopqrstuvwxyz@"
If Allowed.IndexOf(e.KeyChar) = -1 Then
e.KeyChar = Nothing
End If
End Sub
I code at http://tech.reboot.pro