VBScript FileSystemObject/OpenTextFile ReadAll stops reading data at firs character zero

I'm not sure of the terms, so please forgive me:  A supposedly text file is created by MS Access (the ObjectSaveAs function).  The file, when looked at with a hex tool, appears to be written in UniCode, instead of normal ASCII.  When I open the file (in Access) using the FilesSystemObject Object with the OpenTextFile command and try to do a ReadAll, the buffer has nothing but Character Zero's starting at the first Character Zero it finds.  Is this a known bug?  Can I still use the ReadAll function, only differently?  Is there an alternative native VBA command that can easily do the "ReadAll" function without having to code read loops, etc?

Code (without the obvious dimension lines):
            Set F = FSO.OpenTextFile(strTextFile, 1)
            strObjCode = F.ReadAll
            X = InStr(strObjCode, strSearch)

Sample snippet of Data (RSF.txt is the filename):
   RSF.TXT....|....1....|....2....|                                     This is a ruler line (not proportional)
              1 . V.e.r.s.i.o.n. .=.2.0.~                           This is the actual contents (The # 1 indicates First Byte)
                2200101010101010000000000              These two lines are the contents
                5580001010001010306050401              represented in hex (reading vertically)
Everthing from just after the "V" onward appears as character zeros in the strObjCode variable.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try changing this:
Set F = FSO.OpenTextFile(strTextFile, 1)
to this
Set F = FSO.OpenTextFile(strTextFile, 1, False, -1)

There are four paramenters to the OpenTextFile method:

The third is whether to create a new file if it doesn't exist, and the last is open in UniCode or ASCII.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FaulkenatorAuthor Commented:
Neat!  Didn't see that in the help text.  I went back to it, and sure enough, there it is.  Thanks!   Time for a new pair of glasses!

FYI, as an alternative:  I used the Getfile & .Size parameter and used Read(Size) function.  That also worked, but it brings in all the in between zeros!

Thanks.  You get the nod.
No problem, thanks.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.