Visual Basic Programming lesson 12 – Reading data from a text file


A lesson requested by a subscriber. This lesson teaches you how to read data from a text file. In the next few lessons we are also going to talk about how to store data in a text file, which will help you with projects such as develop a high score table in game creation.

Visit to download source code.



  1. Thanks for the video, this is very helpful, but please i'm having a problem, i have a cvs test file with over 800 items, all separated by commas, how do i read only the first 120 items or only a specify numbers of items from the list?

  2. I am working on a project that requires reading a simple csv text file. I struggled for days trying out code that I found on the web. Couldn't get StreamReader code to read single records. Then I stumbled on this. a very simple method that works like a charm! Yu saved my bacon. Thanks a million!

  3. I am looking for online tutor for visual basic 2010 express. Please refer me to one of the visual basic expert.

    you know in gcode (a type of text file ) i have such as this lines

    x10 y12 z20 f100

    i want to make a simple app which reeds the line and send the x,y and z values to each its own variable this means after input this valuse to textbox and for example click read button the x variable value will change to 10 and y=12 and z like this

    whats should i do

  5. Hey how do you make it so you can read the title of the text file? for example textfile1.txt or textfile2.txt ? Thanks

  6. I wrote a program where you can select the extension, the path, the name of the file, and you can write the multi-line text inside the program. Then you just click the button and it makes a new file with the wroten extension, name, and the path and text, or it overwrites the existing file.

  7. How do one get data from a data file from WOT REPLAY file, I would like to analyse my performance, can you give a hint here.

  8. Soooooooooooooooo helpful with my amateur programming project!!! I dont know if your still reading these. but THANK YOU!!!!!!!!

  9. Hi. What if the text file already exist but is on a different folder path? And the text file needs to be on that folder.

  10. Can you make an Tutorial like this but with webclient like FileOpen(FILENUM, WEB.DownloadStrings "", OpenMode.Input)

  11. I have been scouring YouTube for a thorough lesson that covers these details and yours is the first that covered the full steps of it. I really appreciate the video!
    Gonna continue with the series as I type this!

  12. Excellent tutorial! How would you modify the code in your tutorial to automatically read the variables from the variable file on the start up of the application rather than from the ""?

  13. I've been programming Visual Basic 6.0 for years and I've trying to learn Visual Basic .Net on and off for awhile and file manipulation has been the biggest hangup because it is somewhat different than VB6.0.
    These tutorials makes it seem easy to do and I hope to be able learn VB.Net from them.

  14. can you read a string and an integer from the file like a card from 2 to 10 but 11 will become J the following are Q K and Ace. i'm trying to make a card game.


Please enter your comment!
Please enter your name here