I am currently working on a program to track my mile for my monthly expense report for work. Everything is working great, however, I can not for the life of me find a code to write 8 lines from the text file back into the listview on my form. I have found some samples that work for 2 to 4 columns, but not for 8. My code for saving the file is as follows:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim sfile As New SaveFileDialog With sfile .Title = "Choose your path to save the information" .InitialDirectory = "D:\" .Filter = ("ONLY Text Files (*.txt) | *.txt") End With If sfile.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Dim Write As New IO.StreamWriter(sfile.FileName) Dim k As ListView.ColumnHeaderCollection = ListView1.Columns For Each x As ListViewItem In ListView1.Items Dim StrLn As String = "" For i = 0 To x.SubItems.Count - 1 StrLn += k(i).Text + " :" + x.SubItems(i).Text + Space(3) Next Write.WriteLine(StrLn) Next Write.Close() 'Or Write.Flush() End If Me.Close() End Sub
I just need help with writing everything back into the listview when the form loads. I have not had any luck with this part.