VB.Net Tutorial - Read Text File using VB6
In classic VB reading a file is not that easy as we do in vb.net. The first and easy way to access a text file is using the simple file open method available in classic Visual Basic. Using this method, we can allocate a unique file number for opening the file. further the same number has to be used for closing the file handle.
In addition to this, there are various modes a file can be opened. Some of them are Append, Binary, Input, Output, or Random. By default Random will be used.
Read text file in VB.Net
In VB.net we can read files very easily. The System.IO namespace contains really very useful set of functions which can reduce the effort and time in coding file related activities. One of the easiest is reading a text file into string System.IO.File.ReadAllText(FilePath).
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = System.IO.File.ReadAllText(TextBox1.Text)