• Access VBA reads file all at once (2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Access VBA reads file all at once (2003)

    Author
    Topic
    #449099

    I have the following code to read a file and process it:

            Dim intFileNum As Integer
            intFileNum = FreeFile
            Dim strLineIn As String
            Open CurrentProject.Path & "todo" & strTheFile For Input As #intFileNum
            Do While Not EOF(intFileNum)
                        Line Input #intFileNum, strLineIn
    

    the problem is that it reads the entire file at once instead of one line at a time, like I’m expecting.

    If I open the file in TextPad, it shows the lines as individual lines, not one long line of data…

    Any ideas on how to get around that?

    Thanks!

    Viewing 1 reply thread
    Author
    Replies
    • #1100112

      Check post 6566, it may have what you want.

      Else do a search in this forum and check those posts.

    • #1100125

      I Patt’s suggestion doesn’t help, could you attach (a reduced copy of) the text file?

      • #1100751

        Yeah, it had the same results. Attached is a copy of the file…

        • #1100753

          When I copy/paste the CONTENTS of the file to a new file, it works, but the original file does not…

          • #1100762

            You can also open the text file in Word, then save it (without changing anything).

        • #1100759

          The file doesn’t contain carriage returns (ASCII 13), only line feeds (ASCII 10). The Line Input instruction expects either a carriage return or a carriage return followed by a line feed, but not a line feed by itself.

          • #1100764

            So my best option is to loop thru the file, character by character, until I find a line feed and consider that a line for processing, right?

    Viewing 1 reply thread
    Reply To: Access VBA reads file all at once (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: