View Full Version : Textfile objreader readline is missing some data


desmond
02-18-2010, 08:36 PM
Hi,

In my VB.Net form, I'm reading a text file with thousands of lines of data. For somer reason, on just a few of the lines, there is some data missing.

When I check the immediate window for the 'bad' records, and display the text line, it only shows the first 72 characters. If I then do a trim(mid) of the record at position 82, it shows me the rest of the record.

But in my code where I move each line to a textbox, it only shows the first 72 characters.

Perhaps this has got something to do with a 'tab' in the text file???

HELP!!

Dim FileName As String = "C:\Example.txt"
If System.IO.File.Exists(FileName) = TrueThen
Do While objreader.Peek() <> -1
TextLine = objreader.ReadLine() & vbNewLine
TextBox1.AppendText(TextLine)
Loop
objreader.close()
End If

DCrake
02-19-2010, 12:30 AM
You may need to use the Replace() command to check for unusual characters such as tabs and carriage returns.

TextLine = Trim(Replace(TextLine,vbTab,""))

desmond
03-28-2010, 03:29 PM
You may need to use the Replace() command to check for unusual characters such as tabs and carriage returns.

TextLine = Trim(Replace(TextLine,vbTab,""))


Thanks David, this is a good bit of advice, but didn't solve the problem. I eventually found out it was due to unix scripting - dos to unix - special characters (e.g. carriage return / tab etc) hadn't been catered for.