-
November 29th, 2012, 03:41 PM
#1
Dispose of dictionary
Hi all!
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?
Thanks!
Jim
-
November 30th, 2012, 03:21 AM
#2
Re: Dispose of dictionary
Show some code of how your assigning these variables and the dictionary.. maybe there's something not quite right there...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
November 30th, 2012, 03:38 AM
#3
Re: Dispose of dictionary
Have you tried DictionaryObject.Clear before the call to Dispose it?
-
November 30th, 2012, 04:45 PM
#4
Re: Dispose of dictionary
Thanks for the replies!
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|