Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 444651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:17:31+00:00 2026-05-12T21:17:31+00:00

I received this code from one of those nice people here who are willing

  • 0

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.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:17:31+00:00Added an answer on May 12, 2026 at 9:17 pm

    The line of code:

    Dim fso, MyFile, FileName, TextLine
    

    declares things called ‘variables’ of type variant.

    A variable is a bit of space in memory with a name and a type. You use them to let the program know you’re going to be making use of them later on in the code.

    Normally you’d give the variables a type (like integer, or string) but the coder hasn’t, so it has defaulted to variant, which can take on any type (in essence).

    Once you’ve done:

    Set fso = CreateObject("Scripting.FileSystemObject")
    

    then fso contains a bit of code that can do stuff to the file system.

    Set MyFile = fso.OpenTextFile(FileName, ForReading)
    

    Means you’re using the fso functionality to open a filename you specify in the ‘filename’ variable, and you’ve put a reference to it in the ‘myfile’ variable.

    So you can then do further stuff with the file by using the myfile variable.

    The ‘do while’ loop reads through that file one line at a time (myfile.readline) and puts the result into the ‘textline’ variable, which holds a different line of text from the file every time you go round the loop, till the file is finished.

    The idea of this code is to read the file line by line, doing stuff with the contents of each line as you come across it. You could print it, log it, display it to the user, etc, as the title of the sub indicates!

    To be honest the basics about VB are essential for you to be able to interpret such code so I would suggest looking for an online tutorial or a book.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is one of those cases where I had the code working, tried to
I received this error on following code.Is this + sign is not available in
I received >>> THIS <<< error log from a client. I replaced the app
I know this is far fetched, but I've received an IPA game from a
Can't figure this one out. Done research, searched here, online, etc. Still a new
We received this piece of code for an assignment, and after spending a lot
We have received Java code from a software supplier. It contains a lot of
I have some code that someone wants to put on their site. Here is
this is my first time posting here, although I have gotten many great tips
I received this reply on the Live555-mailing list: FEC is not needed for UDP.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.