Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove "Invisible" Control Characters in VB.Net

I am currently reading in a text file in VB.Net using

Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText(file)

File contains several lines of text and when I read in the text file, it knows that they are on separate lines and prints them out accordingly.

However, when I try to split fileReader into an array of the different lines, the line break seems to stay there, even if I use Split(ControlChars.Cr) or Split(ControlChars.NewLine). It will successfully split it into the separate lines but when I display it, it will "push" the text down a line, like the line break is still there...

Does anyone have any ideas on what is going on and how I can remove these "invisible" control chars.

Text File:

Test1
Test2
Test3
Test4

fileReader:

Test1
Test2
Test3
Test4

lines() printout

Test1

Test2

Test3

Test4

like image 659
Kyle Uithoven Avatar asked Jan 27 '26 12:01

Kyle Uithoven


1 Answers

Use trim() on each line, it'll remove extraneous whitespace.

like image 123
Cyclone Avatar answered Jan 30 '26 04:01

Cyclone