Creating a text filter isn’t as easy as it sounds. At least, in Visual Basic its not.
I spent several hours figuring out how to bypass all the little errors I get when I try to remove text from a Textbox.
Well, anyone else who needs to know how, here you go.
[code]
For i As Integer = 0 To TextBox1.TextLength - 1
Try
If TextBox1.Text.Chars(i) = “.” Or TextBox1.Text.Chars(i) = “*” _
Or TextBox1.Text.Chars(i) = “=” Or TextBox1.Text.Chars(i) = “,” Or _
TextBox1.Text.Chars(i) = “!” Or TextBox1.Text.Chars(i) = “_” Or TextBox1.Text.Chars(i) = “/” _
Or TextBox1.Text.Chars(i) = “(” Or TextBox1.Text.Chars(i) = “)” Or TextBox1.Text.Chars(i) = “’” _
Or TextBox1.Text.Chars(i) = “” Or TextBox1.Text.Chars(i) = “&” Or _
TextBox1.Text.Chars(i) = “-” Then
TextBox1.Text = TextBox1.Text.Replace(TextBox1.Text.Chars(i), "")
End If
Catch ex As Exception
End Try
Next[/code]
Remember, you can always change the code to filter other characters.