M MathiasM Active Member Licensed User Mar 11, 2021 #1 Hello I'm tearing my hair out over here, a Map object contains a bunch of strings, I try to get a value by a key. But the value is always null. I have screenshots of my debug process: The Map, containing the string "B1A" The value I'm passing to the Get on that Map is B1A The result is Null To be complete, this is the code: Anyone has a idea what I'm doing wrong? Thanks for any help.
Hello I'm tearing my hair out over here, a Map object contains a bunch of strings, I try to get a value by a key. But the value is always null. I have screenshots of my debug process: The Map, containing the string "B1A" The value I'm passing to the Get on that Map is B1A The result is Null To be complete, this is the code: Anyone has a idea what I'm doing wrong? Thanks for any help.
OliverA Expert Licensed User Longtime User Mar 11, 2021 #2 Maybe there are one or may spaces at the end of the key value (or non-printable characters). Upvote 0
E emexes Expert Licensed User Longtime User Mar 12, 2021 #3 Get the map keys using .GetKeyAt, and have a very close look at the length and character numbers/codes of the "B1A" entry. Also, B1A is a valid hex number, and unexpected interpretation/casting of numbers has sometimes tripped me up. Upvote 0
Get the map keys using .GetKeyAt, and have a very close look at the length and character numbers/codes of the "B1A" entry. Also, B1A is a valid hex number, and unexpected interpretation/casting of numbers has sometimes tripped me up.
josejad Expert Licensed User Longtime User Mar 12, 2021 #4 What do you get if you try: Code: Copy For Each Key As String In Map.Keys Log(Key) Dim Value As Object = Map.Get(Key) Next Upvote 0
What do you get if you try: Code: Copy For Each Key As String In Map.Keys Log(Key) Dim Value As Object = Map.Get(Key) Next
Erel B4X founder Staff member Licensed User Longtime User Mar 12, 2021 #5 What is the output of? Code: Copy For Each Key As String In Map.Keys Log(Key & ", " & Key.Length) Next Upvote 0
What is the output of? Code: Copy For Each Key As String In Map.Keys Log(Key & ", " & Key.Length) Next
M MathiasM Active Member Licensed User Mar 12, 2021 #6 Thanks for the help people. I found the issue. As seen in my second image, the value is "B1A", not B1A. So including the " " signs. Very stupid of me, I assumed the "" sign was the IDE's way of showing it was a string value. Thanks for guidance! Erel said: What is the output of? Code: Copy For Each Key As String In Map.Keys Log(Key & ", " & Key.Length) Next Click to expand... It showed 5 instead of 3. Which was the point I understand the problem (way too long after hitting the problem). Thanks! Upvote 0
Thanks for the help people. I found the issue. As seen in my second image, the value is "B1A", not B1A. So including the " " signs. Very stupid of me, I assumed the "" sign was the IDE's way of showing it was a string value. Thanks for guidance! Erel said: What is the output of? Code: Copy For Each Key As String In Map.Keys Log(Key & ", " & Key.Length) Next Click to expand... It showed 5 instead of 3. Which was the point I understand the problem (way too long after hitting the problem). Thanks!