Solved

Reading text file only reading last line

Posted on 2006-06-21
4
254 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
ID: 16955844
simple
Sdata = sinputline
should be
SData = SData + sInputline
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 16955848
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
ID: 16955858
lol now i feel stupid i dont know what i was thinking. lol thx
0
 
LVL 12

Expert Comment

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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

790 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