There are many ways to write text or string to a file. In this tutorial, we are going to use StreamReader
class.
StreamReader
is designed for character input in a particular encoding, whereas the Stream
class is designed for byte input and output. Use StreamReader
for reading lines of information from a standard text file.
Required Preferences
- System.Runtime.Extensions.dll for
StreamReader
class
Procedure
- Open the previous project from Write Text To File In Visual Basic Tutorial and rename the project to ReadFileVB or create a new project but it is recommended to use the existing project in the said tutorial.
- Once the project is loaded, open the FormMain and add new CommandButton and set the name property to ButtonReadFile and text property to Read File
- Double click on to ButtonReadFile to view the code then copy the codes below and paste it to ButtonReadFile_Click event.
- Save the project for the future tutorial and run it.
- That's all. I hope that you enjoy my tutorials. Subscribe to this page for more.
1 | Using OpenFile As New OpenFileDialog |
Comments
Post a Comment