Solved

Reading text file only reading last line

Posted on 2006-06-21
4
249 Views
Last Modified: 2010-04-07
For some reason im trying to read a text file with about 50 lines and it keeps only reading the last line???

    Dim sData As String
    Dim sinputline As String
    Dim ff As Integer
    ff = FreeFile
    sData = Empty

    Open sUpdateScriptSys For Input As #ff
        Seek #1, 1
        Do While Not EOF(ff)
            Line Input #ff, sinputline
            sData = sinputline
            DoEvents
        Loop
    Close #ff
0
Comment
Question by:thaburner
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
fruhj earned 200 total points
Comment Utility
simple
Sdata = sinputline
should be
SData = SData + sInputline
0
 
LVL 95

Expert Comment

by:Lee W, MVP
Comment Utility
No, it's reading every line... you are just overwriting it each iteration of the loop.

What exactly are you trying to do - because the code you shown is just reading in the line and moving to the next line and not doing anything.
0
 

Author Comment

by:thaburner
Comment Utility
lol now i feel stupid i dont know what i was thinking. lol thx
0
 
LVL 12

Expert Comment

by:fruhj
Comment Utility
been there and done that so don't feel bad.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now