Is there a way to merge two dictionaries into one assuming there are no duplicate keys?
for each zKey as Variant in dict1.keys if dict2.haskey(zKey)=false then dict2.value(zKey)=dict1.value(zKey) else msgbox "dup key" end if next
NOTE : For illustration purposes only, cut and paste at your own risk
I would leave away the check and just put all values into destination dictionary:
for each zKey as Variant in dict1.keys
OP mentioned “no duplicate keys”… and if he is POSITIVE “that will never happen”, then I agree… but I’m not that optimistic when it comes to data
Isn’t the thing about dictionaries that you dont get duplicate keys?
Last value in wins the prize.
Im with Christian… ditch the check.
If the two dictionaries dont have a common key, no rworries
If they do, the value from the ‘added’ dictionary overwrites the first
No you don’t get duplicate keys… but if the key already existed, the merge would wipe out the original data
Guess I am just overly cautious when it comes to possibly wiping out data… but the OP is free to do as they please…