Hi all,
I'm trying to create a program... (Who isn't here -.-)
Well, I want to edit an entry in my current dictionary, but it just adds it.
This is my code:
I want to delete the text file and then "re-write" it all back, then load it again. Anyone have any ideas?Code:Private Sub SaveData() SR.Close() Dim SW As StreamWriter My.Computer.FileSystem.DeleteFile("Dictionary.txt") SW = New StreamWriter("Dictionary.txt") For Counter = 0 To NumTerms SW.WriteLine(Term(Counter)) SW.WriteLine(Definition(Counter)) Next SW.Close() End Sub Private Sub LoadDictionary() NumTerms = -1 SR = New StreamReader("Dictionary.txt") Do While SR.EndOfStream = False NumTerms += 1 Term(NumTerms) = SR.ReadLine Definition(NumTerms) = SR.ReadLine Loop End Sub Private Sub btn_Save2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Save2.Click Term(lst_results.SelectedIndex) = txt_Name.Text Definition(lst_results.SelectedIndex) = txt_Description.Text SaveData() LoadDictionary() End Sub




Reply With Quote