Link to home
Start Free TrialLog in
Avatar of Jay Balu
Jay Balu

asked on

VB6 string variable truncating data that it reads from a file

Experts,

I have two questions
1. When I am reading a 600kb text file (HTML code) into a string variable, it is truncating pretty much half of the content. Here is the code I have... where am I going wrong?
Dim fso As New FileSystemObject
Dim f As File
Dim fsoStream As TextStream
Dim strLine As String
Set f = fso.GetFile("C:\Users\Neanderthal\Desktop\MyProj\GMATClubLog.txt")
Set fsoStream = f.OpenAsTextStream(ForReading)
' Read the file line by line, printing the results to the Form
Do While Not fsoStream.AtEndOfStream
     strLine = fsoStream.ReadLine
     Debug.Print strLine
Loop
Len(strLine)

fsoStream.Close
Set fsoStream = Nothing
Set f = Nothing
Set fso = Nothing

Open in new window


2. Basically why I want to read the whole content of the text file is because I want to extract a repeating set of data based on the search criteria . And this is the repeating code. How can I achieve this using vb 6 code?

<td class="topicsName" style="width:100%">
<a class="newestPostIcon" href="http:someURL.com"></a>
<a title="some text" href="http://I want to extract this link.html" ></a> 
</td>

Open in new window


I am attaching the text file to this post.

Thanks!
temp.txt
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Take a look at the file in a text editor and see if there's anything unusual about the line following the last one that prints in the Immediate Window. It may be that there's something in the file that is being interpreted as EOF.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jay Balu
Jay Balu

ASKER

Martin Liss - Thanks for your response. I was in fact mistaken, What happened was when I tried to print it in the VB Immediate window, it was not printing completely (could there be a limit on how much contact can be printed in that window?). But when I wrote it back to a text file, it was printing everything there. So... false alarm. Thanks for your answer though.
The Immediate Window will show at most 199 lines.

You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
Would you be interested in taking a quick look at my other question too?

https://www.experts-exchange.com/questions/28568498/Extract-data-from-html-td-tags-using-vb6.html

Sorry, if I am hijacking this post.