Textfile objreader readline is missing some data

desmond

Registered User.
Local time
Tomorrow, 07:46
Joined
Dec 8, 2009
Messages
28
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
 
You may need to use the Replace() command to check for unusual characters such as tabs and carriage returns.

TextLine = Trim(Replace(TextLine,vbTab,""))
 
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.
 

Users who are viewing this thread

Back
Top Bottom