Open FileName For Input vs. FileSystemObject.OpenTextFile - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Open FileName For Input vs. FileSystemObject.OpenTextFile

Have strange issue at work. Need to read a report that has been saved as a .txt file, pull out certain info and save in an Excel file for my user.

Using Mid function to grab very specific data from each line read in from input file.

Using the old Open FileName For Input As #1, my app gets tripped up when it encounters some non-ascii characters that are in a specific column of the input file.

However, if I use FileSystemObject as follows, I can access all info I need without any issues whatsoever with the non-ascii values:

Set fs = New FileSystemObject
Set input_file = fs.OpenTextFile(strMFM032Path, ForReading, TristateFalse)
Do While Not input_file.AtEndOfStream
strFullRecord = input_file.ReadLine

Can anyone explain why that might be?

Comments

  • JomacJomac Posts: 231Member
    : Have strange issue at work. Need to read a report that has been saved as a .txt file, pull out certain info and save in an Excel file for my user.
    :
    : Using Mid function to grab very specific data from each line read in from input file.
    :
    : Using the old Open FileName For Input As #1, my app gets tripped up when it encounters some non-ascii characters that are in a specific column of the input file.
    :
    : However, if I use FileSystemObject as follows, I can access all info I need without any issues whatsoever with the non-ascii values:
    :
    : Set fs = New FileSystemObject
    : Set input_file = fs.OpenTextFile(strMFM032Path, ForReading, TristateFalse)
    : Do While Not input_file.AtEndOfStream
    : strFullRecord = input_file.ReadLine
    :
    : Can anyone explain why that might be?
    :

    It depends on what method you use to read the data, for instance there is a big difference between using.
    [code]
    Input
    [/code]
    and[code]
    Input #
    [/code]

    Post your code for more info.
    ______
    [size=2][b][blue]J[/blue]omac.[/b][/size]

Sign In or Register to comment.