How to read a file line by line to the end in VB.NET
by Preetha[ Edit ] 2012-09-14 10:00:37
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim file_dir As String = "file.txt"
'parse file
Try
Dim sr As StreamReader = New StreamReader(file_dir)
Do Until sr.EndOfStream
TextBox1.Text += vbNewLine + sr.ReadLine()
Loop
sr.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Class