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.
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- file = Environment.GetCommandLineArgs()
- If file.Length > 1 Then
- Current = (file(1).ToString())
- End If
- End Sub
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
Subscribe at my YouTube Channel at: Ser Bermz
Visit my website at: www.campcodes.com
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.