Hi all,
Really need some help with this, basically I have a text file located at "C:\test.txt" it is populated regularly with visitor information (date & time, name, company etc..).
I'm trying to read back the last 30 lines of that text file and populate it in to "CheckedListBox1".
I've found the following code, but I don't know how to modify it further to populate "CheckedListBox1". When I tried earlier all I could manage to do was populate it with the last 30 line numbers of the file! I can't actually get the line to show in it :(
Can anyone help a learning newbie?
Really need some help with this, basically I have a text file located at "C:\test.txt" it is populated regularly with visitor information (date & time, name, company etc..).
I'm trying to read back the last 30 lines of that text file and populate it in to "CheckedListBox1".
I've found the following code, but I don't know how to modify it further to populate "CheckedListBox1". When I tried earlier all I could manage to do was populate it with the last 30 line numbers of the file! I can't actually get the line to show in it :(
Can anyone help a learning newbie?
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fileNameAndPath As String = "C:\test.txt"
Dim fileContent As String
Dim fileLines() As String
Using sr As New System.IO.StreamReader(fileNameAndPath)
fileContent = sr.ReadToEnd
fileLines = fileContent.Split(System.Environment.NewLine.ToCharArray)
If fileLines.Count >= 30 Then
For lineNumber As Integer = fileLines.GetUpperBound(0) - 29 To fileLines.GetUpperBound(0)
Next
End If
sr.Close()
End Using
End Sub
End Class