How to make listbox read a text file in visual basic
Автор: Richard Grant
Загружено: 2011-08-26
Просмотров: 24026
Описание:
This is a short tutorial on how to make a listbox ready a text file inside your computer.
Here is the code:
Public Class Form1
Dim streamer As IO.StreamReader 'Makes streamer identify
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.Clear() 'makes sure it doesn't already have text
streamer = IO.File.OpenText("C:\users\Richard\desktop\sample.txt") 'Finds the location of the txt
Dim mystring() As String = streamer.ReadToEnd.Split(vbNewLine) 'reads the text file
ListBox1.Items.AddRange(mystring) 'adds the text to the list box
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
End Sub
End Class
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: