merydion
asked on
An interesting observation re: VB6 & Dictionaries
I use dictionaries extensively to keep track of data within the program.
In this case, I was using the dictionary to determine which records should be deleted.
Unfortunetley, all records were being deleted (test only, thank goodness!).
This is what I learned:
If you are stupid, like I was apparently, and get the sequence mixed up just a wee little bit...
vKey = gRecord.Field("MasterKey")
sDictData = gDict.Item(vKey)
If Not gDict.Exists(vKey) Then SkipStuff
... process deletes
----------------
That code would ADD the value to the data dictionary, regardless of whether it is there or not!
vKey = gRecord.Field("MasterKey")
If Not gDict.Exists(vKey) Then SkipStuff
sDictData = gDict.Item(vKey)
... process deletes
---------------
This works fine.
Thought I would share this... and perhaps, if someone has an observation to share back, that would be equally interesting.
In this case, I was using the dictionary to determine which records should be deleted.
Unfortunetley, all records were being deleted (test only, thank goodness!).
This is what I learned:
If you are stupid, like I was apparently, and get the sequence mixed up just a wee little bit...
vKey = gRecord.Field("MasterKey")
sDictData = gDict.Item(vKey)
If Not gDict.Exists(vKey) Then SkipStuff
... process deletes
----------------
That code would ADD the value to the data dictionary, regardless of whether it is there or not!
vKey = gRecord.Field("MasterKey")
If Not gDict.Exists(vKey) Then SkipStuff
sDictData = gDict.Item(vKey)
... process deletes
---------------
This works fine.
Thought I would share this... and perhaps, if someone has an observation to share back, that would be equally interesting.
ASKER
The code is commented, I just didn't do so here for brevity.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
please comment the code so you and others will understand it later also.