Test text file |
First you have to add the following code!
Imports System.IO
After add the code to the button Open file.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim OpenFileDialog1 As New OpenFileDialog
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim lines = File.ReadAllLines(OpenFileDialog1.FileName)
ListBox1.Items.Clear()
ListBox1.Items.AddRange(lines)
End If
End Sub
When you open the file it looks like the image bellow.
Open text file in ListBox |
You can check my other posts about ListBox:
- Insert data from TextBox and InputBox into ListBox
- Delete Selected Item from ListBox in Visual Basic 2015
No comments:
Post a Comment