Settings
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
This will save the listview items to file when it closes, and it will load them when it next runs:
Code: Select all
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim lines As String() = File.ReadAllLines("items.txt")
For i As Integer = 0 To lines.Count - 1
ListBox1.Items.Add(lines(i))
Next
End Sub
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
File.Delete("items.txt")
For i As Integer = 0 To ListBox1.Items.Count - 1
File.AppendAllText("items.txt", ListBox1.Items(i) & vbCrLf)
Next
End Sub
Copyright Information
Copyright © Codenstuff.com 2020 - 2023