How to make my own text file reader in vb.net?
Step1:
Open Microsoft visual studio
Step2:
Create file newà windows applicationàrename it as text file reader
Step3:
Drag and drop the list box, three buttons,
Step4:
Change the form properties as you wish
Step5:
Copy the below code and paste in code window
Public Class Form1
Private SubButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton1.Click
Using FD As New OpenFileDialog()
FD.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
If FD.ShowDialog = Windows.Forms.DialogResult.OK Then
ListBox1.Items.Clear()
ListBox1.Items.AddRange(IO.File.ReadAllLines(FD.FileName))
End If
End Using
End Sub
Private SubButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton2.Click
Close()
End Sub
Private SubButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesButton3.Click
ListBox1.Text = ""
End Sub
Private SubForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
ListBox1.Text = ""
End Sub
End Class
Output:
Read the text file just click the read button to read.
No comments:
Post a Comment