How to read a .txt file in

Submitted on: 1/1/2015 12:43:00 PM
By: Sammy Ageil (from psc cd)  
Level: Beginner
User Rating: By 3 Users
Compatibility: VB.NET
Views: 2330
     Just to show how to read a txt or .dat file in

Private Sub btnReadTextFile_Click(ByVal sender _ As System.Object, ByVal e As System.EventArgs) _ Handles btnReadTextFile.Click 'first lets create a form, add a command button on it and create a txt file called my textfile.txt and save it in C:\
paste this code into the click event of the command button
Dim Strmyfile As String = FreeFile()
Dim strLine As String
' first variable to hold our freefile you can
'replace it with a number if you wish
FileOpen(Strmyfile, "C:\FRONTPG.LOG", _ OpenMode.Input, OpenAccess.Read, _
OpenShare.Shared, -1)
'once the file is opened
'loop through every line and copy them to our
Do While Not EOF(Strmyfile)
strLine = LineInput(Strmyfile)
'copy the results to
'messagebox to show it
End Sub
Hit F5 to run the app

Other 1 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

To post feedback, first please login.