Remove "Non Text / Numeric" values from String
Posted on 2010-09-02
I've developed a VB.NET application that does the following
1) Opens up a Text File
2) Searches through the text file line by line to find specific strings of information in the row.
3) After searching through the row, it inserts information into an SQL Server database.
4) From SQL Server, I export the data into a fixed width format text file.
Here is my problem. When I export the file to the fixed width format from SQL Server, the fixed width layout is not maintained. For example, the first field in my export has a width of 50. When I export to the fixed width, there are records where this field will have a width of 51 which throws the rest of the layout off by 1 character.
I believe the reason for this is that there is some type of "non-text" character in the string such that when I export to text file it adds a space to the width.
Is there a way that I can remove these types of characters from the string value within VB.NET?
I think that Regular Expressions would be the way to go, but I'm not sure how to do this.