I have a dictionary that I am using for a program and I would like to be able to close the dictionary without closing the form.
I have tried unload, dispose and everything I can think of.
The data is displayed in a listbox and a textbox. I can clear these but, of course, it doesn't release all of the variables. So if I try to reload the file I get a key already exists message.
So, is there any way to close the form data and release all of the key/value pairs?
If I try to clear then dispose it exits the app and that is not what I am trying to do......
The code that I am using to create the dict is pretty straightforward.
Code:
'Open File
Private Sub btnOpen_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnOpen.Click
If c4wFile.ShowDialog() = Windows.Forms.DialogResult.OK Then
srFileReader = System.IO.File.OpenText(c4wFile.FileName)
strLast = srFileReader.ReadLine()
Do Until strLast = ""
SplitSTR = Split(strLast, "|")
lbxName.Items.Add(SplitSTR(0))
dict.Add(SplitSTR(0), SplitSTR(1))
strLast = srFileReader.ReadLine()
Loop
srFileReader.Close()
srFileReader.Dispose()
End If
End Sub
I am just having a problem closing the file for some reason.
Bookmarks