VBScript FileSystemObject/OpenTextFile ReadAll stops reading data at firs character zero
Posted on 2008-01-30
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.