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.
11 posts Page 2 of 2
Contributors
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Settings
mandai
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
11 posts Page 2 of 2
Return to “Tutorial Requests”