There could be a few reasons why entries are being duplicated in your VBA Dictionary when using CStr for keys:
1) Case sensitivity: CStr converts all keys to strings, which may cause issues if there are keys that differ only in case. For example, "Hello" and "hello" would be treated as different keys. To avoid this, you can use LCase or UCase to ensure that all keys are in the same case.
2) Trailing spaces: If your input strings contain trailing spaces, CStr may treat them as different keys. To avoid this, you can use the Trim function to remove any leading or trailing spaces before using CStr.
3) Null or empty values: If your input values are null or empty, CStr may convert them to the same string value, resulting in duplicate entries in the dictionary. To avoid this, you can add a check to ensure that the key is not null or empty before adding it to the dictionary.
Overall, it is important to ensure that your keys are unique and consistent when using a Dictionary object in VBA.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-07-03 07:17:51 +0000
Seen: 13 times
Last updated: Jul 03 '23
What is the method to write the following regular expression avoiding catastrophic backtracking?
Do api keys meet the requirements of ASVS standards?
What is the most effective approach to establish foreign keys for three adjacent tables?
How can I check in WebTestClient that the JSON contains only certain specified keys?
What characters are permitted for translation keys in i18next?
Does it make sense that the speed of synchronous `multi_get` exceeds asynchronous `get`?