File Content Sorter in VB.NET
This tutorial will teach you how to create a program that sorts the content of file in vb.net.
Now, let's start this tutorial!
1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add one button named openBTN and an OpenFileDialog1 that we will use to open a particular file such as text file.
3. Now, we will do the coding.
We will first import the IO library.
- Imports System.IO
Then, we will declare the following variables below that we will use for a sub procedure.
- Dim Current As String
- Dim myWords As New List(Of String)
- Dim word() As String
- Dim I As Integer = 0
- Dim file As String()
We will then create a sub procedure named ProcessFile() to sort the content of the text file that we will going to choose.
- Private Sub ProcessFile()
- word = System.IO.File.ReadAllLines(Current)
- For Each Temp As String In word
- I += 1
- FileOpen(1, Current, OpenMode.Output)
- For Each curWord As String In myWords
- PrintLine(1, curWord)
- End Sub
And an OpenFile() sub procedure to trigger opening any text files.
- Private Sub OpenFile()
- With OpenFileDialog1
- .Filter = "Text Files (*.txt)|*.txt|Rich Text Files (*.rtf)|*.rtf"
- .FileName = ""
- End With
- End Sub
Lastly, put this code in your Form_Load.
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware