Set File_Object = CreateObject("Scripting.FileSystemObject")
Set File_Xml = File_Object.OpenTextFile(Str_Xml_File)
a = File_Xml.readline
I wanted to read each line till the end of file.I tried it like these
while EOF() 'says argument not optional
while EOF(File_Xml) ' says that Type mismatch it must be an integer
what is the argument to the EOF ? Please tell me how to read the contents of file using the condition EOF in Vba. Thanks
File_Xmlis aTextStreamobject. You can use theAtEndOfStreamproperty to test if you’ve met the end of the file, e.g.File_Xml.AtEndOfStream.The
EOFcomes from the days when you only dealt with ‘real’ files, and you had a limited number of file handles per process. It takes as its argument a file handle id. This is still true today, but we also have streams to work with.The TextStream is a stream, which is higher abstraction than a ‘file’. A stream might be a file, or a network connection, or anything that conforms to the interface. As such I don’t believe it gets a real file handle id, and therefore the EOF function isn’t relevant.