Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is "Dim fso, MyFile, FileName, TextLine" in VBA?
    primarykey
    data
    text
    <p>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:</p> <pre><code>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 &lt;&gt; True TextLine = MyFile.ReadLine '' Do stuff to TextLine Loop MyFile.Close End Sub </code></pre> <p>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:</p> <pre><code>Dim fso, MyFile, FileName, TextLine </code></pre> <p>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?</p> <p>I've read this: <a href="http://msdn.microsoft.com/en-us/library/h7se9d4f(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/h7se9d4f(VS.85).aspx</a> </p> <p>and this: <a href="http://msdn.microsoft.com/en-us/library/ebkhfaaz(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ebkhfaaz(VS.85).aspx</a></p> <p>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. </p> <p>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.</p> <p>So, please, anyone, explain to me in simple terms what "fso" is. Precisely, what the third line of the code above is all about.</p> <p>Thank you all in advance. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload