Hello -- this is probably super easy so forgive my lack of knowledge here ... but can someone help me out with this:
I have a VB program that parses a text file. Within that text file, however, are "unrecognized characters" that show up as blocks when the file is opened in Notepad. Ex -- DCCG00000
When I actually parse some text from one of these files that includes this character and output it to the Console it appears as a double arrow similar to this: DCCG00000<->
How do I programmatically identify and remove these characters
TIA!

Remove invalid character from string
bkustel
If you just wanted to remove non-printable characters, you could create a function:
Public Function CleanString(ByVal Input As String) As StringDim poTemp As New System.Text.StringBuilder
Dim piIndex As Integer
For piIndex = 0 To Input.Length - 1
If Input.Substring(piIndex, 1) >= " " And Input.Substring(piIndex, 1) <= "z" Then
poTemp.Append(Input.Substring(piIndex, 1))
End If
Next
CleanString = poTemp.ToString
End Function
You can change the " " and "z" in the IF to whatever ASCII values you desire in order to keep just the characters you wanted.
Cwilson
Thanks everyone!
Learning VB
Hope this helps you a bit.
VOC
Besides having the following character methods to test your characters:
Char.IsLetterOrDigit() Char.IsPunctuation() Char.IsSymbol()You can create a function that fits your needs such as:
Public
Function IsValidCharacter(byval c as Char)as booleanif AscW(c) < 40 or AscW(c) > 176 Then
Return False Else Return True End If End Function