Search VB 2010

Wednesday, February 05, 2014

Visual Basic Online Course - Read Text File

Visual Basic 2010 - How to Read Text File(s)

VB 2010 Read Text Files
VB 2010 Read Text Files
Introduction

In order to read from a Text File then a Text File has to be present (Present = Known Path), the path of a Text File is just like any other path of any file it is String, for example :
C:\Folder\File.txt
The path to the File.txt is (C:\Folder\File-Name.Extension), so the path to the File Text = Path + File-Name + extension. Text Files can be present locally (on the same machine) or from external place (on the web) for example :
ftp://10.0.0.27/Folder/File.txt
As long as this Path is present and accessible then Reading Text File in VB 2010 is just so easy job to do. We can store the path to the Text File into a String variable to use it in our VB 2010 project :
Dim LocalFilePath as String = ("C:\Folder\File.txt")
Dim WebFilePath As String = ("ftp://10.0.0.27/Folder/File.txt")
The problem with Text Files hosted on the web, is that it has to be accessible in order to read it or write it, you have to provide  a User Name and Password to gain access to those files for most of the times because of security issues, unlike reading Text Files from local storage devices, there is no need to provide credentials or authentications to be able to read them.

Reading from Local Text Files in VB 2010

We will use File Reader to read String stored in a Text File,we will use basics of reading Text Files.

1) Create VB 2010 Windows Form Project (WindowsApplication1) and save it to (D:\)
2) Add TextBox (Name : TxtFromFile, MultiLine : True)
3) Create Text File (MyFile.txt) and place it in the project folder
Path to MyFile.txt is (D:\WindowsApplication1\Bin\Debug\)
4) Write to MyFile.txt those two lines :
Hello
Visual Basic Online Course
5) Save and close the file.

Now, the project will :
Open the Text File to read on the Form_Load() event
Displays the String in the TextBox (TxtFromFile)

Code


Here are some online Visual Basic lessons and courses :

12 comments:

  1. I am ѕure this piece oof writing has touched all the internet people,
    іts rеally really fastidious piece οf writing oon building up new website.


    Also visiіt mmy website :: laurel burch t shirts

    ReplyDelete
  2. My partner and I stumbled over here by a different page
    and thought I should check things out. I like what I see
    so now i'm following you. Look forward to
    finding out about your web page repeatedly.

    Here is my web page: CCTV in West Sussex

    ReplyDelete
  3. Yߋu should bе a part of a contest for one of the hiցhest quality sites оn the
    internet. I will recommend thiis blog!

    Ӎy web-site :: Payday Loan Rate

    ReplyDelete
  4. Hello, after reading this awesome piece of writing
    i am also glad to share my experience here with friends.



    My web page ... payday lenders

    ReplyDelete
  5. Excellent blog here! Also your site loads up
    fast! What web host are you using? Can I get your affiliate link to your host?

    I wish my website loaded up as fast as yours lol

    Here is my blog post ... no credit check loans

    ReplyDelete
  6. Сurrently іt sounds like Movable Type is tҺе top blogging poatform аvailable right nߋw.
    (from what I've read) Ιs that what уou're using on ʏour blog?


    Alѕo visit my web-site :: Dr Oz Garcinia Cambogia

    ReplyDelete
  7. Αfter lօoking at a number off thе blog articles on your site,
    І really liҡe your wɑy of writing a blog.
    I book-marked it to mү bookmark ite list and will bе checking bacҝ in
    thе ոear future. Ρlease visit my web sitge aas well and
    tell me how үou feel.

    Feeel free tto ssurf tօ my web site ... Dr Oz Garcinia Cambogia

    ReplyDelete
  8. First of all I want to ѕay excellent blog! Ι had a quick question that I'd lіke to aѕk if you do
    not mind. I ԝas curious to fіոd out hߋw you center ƴourself annd сlear yօur
    head befoге writing. I Һave had a tough time clearing mү mond iո gettiոg my thoսghts out thеrе.
    I tгuly ddo tаke pleasure inn writing ƅut іt just seems like
    thе first 10 tߋ 15 minutes arre gеnerally wastedd simply jujst tгying to figure oսt hhow to begin.

    Anʏ suggestions օr hints? Appreciate it!

    My web blog Dr Oz Garcinia Cambogia

    ReplyDelete
  9. This paragraph ρrovides сlear idea fοr the new people of blogging,
    tҺat really how too do running a blog.

    Review mʏ web site: Dr Oz Garcinia Cambogia

    ReplyDelete
  10. Hi : Thank you for your post regarding visual basic, I try and working fine.. Thanks

    ReplyDelete

Visual Basic Online Course

Visual Basic Courses - Share