I received this code from one of those nice people here who are willing to spend their time and energy to share their knowledge with noobs:
Sub ReadLinesFromAFileOneAfterAnother ()
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, MyFile, FileName, TextLine
Set fso = CreateObject("Scripting.FileSystemObject")
FileName = "c:\testfile.txt"
Set MyFile = fso.OpenTextFile(FileName, ForReading)
'' Read from the file
Do While MyFile.AtEndOfStream <> True
TextLine = MyFile.ReadLine
'' Do stuff to TextLine
Loop
MyFile.Close
End Sub
While I know what task this code performs, I would still want to know what each of its elements means and does. Can anyone, please, explain to me what the third line of this code is all about:
Dim fso, MyFile, FileName, TextLine
What is "fso" in the first place? I know it stands for "File System Object", but it does little to explain to me what it actually is and what it accomplishes. What do those three following words mean ("MyFile", "FileName", "TextLine")? Are they some kind of parameters of something?
I've read this: http://msdn.microsoft.com/en-us/library/h7se9d4f(VS.85).aspx
and this: http://msdn.microsoft.com/en-us/library/ebkhfaaz(VS.85).aspx
but it feels like those materials are wrriten for those who themselves would be able to write them - I hardly understood anything. Some things, of course, are more or less clear, but there are so many other terms and words that I don't know! Eventually, there isn't one whole complete and clear picture.
So, I gave up and decided to come back here. This site is probably one of the few on the internet (in fact I haven't met any other) that has declared in its rules: "No question is too trivial or too "newbie"". This gives me a kind of ground for asking this present question.
So, please, anyone, explain to me in simple terms what "fso" is. Precisely, what the third line of the code above is all about.
Thank you all in advance.