We help IT Professionals succeed at work.
Get Started

legacy VB6 - readline not working for new text files - reads entire file instead

Last Modified: 2013-11-26
I am updating a legacy VB6 application that reads a text file line by line, and a different developer has updated the program that writes this text file, so now instead of reading one line, the legacy program reads the entire file. Theoretically we should be able to drop the files in the same program without changes, but this not recognizing line ends makes our simple legacy parser not work.

I checked and there is still a newline \n char written at the end of each line. I figure that he must be using a different encoding type or something where the readline does not recognize the end of the line in the new files - no problem with textpad and notepad putting in the new line though. The code fragment attached shows the readline used.

I tested with an older file, no problem, reads just one line fine, but a newer file created with the new app (which is simply a different version of Director with Flash embedded instead of pure director and no Flash) reads the whole file, which is bad as the VB6 program parses and uses each line before the next one is to be read.

The "lots of work" solution (some of which is political) is to have him write a stop char of some type at the end of each line, then split from there, hence not maxing points here at EE, but I'd like to know what is going on and solve it at my end if possible.

I've stripped out the personal data on a couple of files, an old one that works and a new one with just test info in it, and would appreciate any suggestions on how to tell what is going on.

(in sample ts is a textstream object)
Set ts = filPostData.OpenAsTextStream

' read the first line
    strData = ts.ReadLine

Open in new window

Watch Question
Top Expert 2012
This problem has been solved!
Unlock 2 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE