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
Visual Basic ClassicVisual Basic.NETVB Script

Avatar of undefined
Last Comment
Jay Balu

8/22/2022 - Mon
Martin Liss

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
Martin Liss

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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.
Martin Liss

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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Jay Balu

ASKER
Would you be interested in taking a quick look at my other question too?

https://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28568498.html

Sorry, if I am hijacking this post.