So im trying to do a simple system in my VB Express Edition 2008 and what it does is add some car models (example) to a list box and stores it in a .txt file for future use. But when the user clicks a delete button it should delete from both the listbox and the .txt. Any Ideas?

I have to use only the FileOpen(OpenMode.Append or OpenMode.Input/Output) functions. Please Help! Thanks

Try this code,

....
 If ListBox1.SelectedIndex <> -1 Then
            ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
            System.IO.File.WriteAllLines("file.txt", ListBox1.Items.Cast(Of String)().ToArray())
 End If
....
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.