Shay Well-Known Member Licensed User Longtime User Jan 25, 2015 #1 This is from B4A, how do I do it on B4i, there is no GetValuteAt Code: For i=0 To CityMap.Size-1 City = CityMap.GetValueAt(i) If City.CompareTo(Main.MYCity) = 0 Then Main.MyCityCode = CityMap.GetKeyAt (i) Log("Got City Code") i = CityMap.Size - 1 End If Next
This is from B4A, how do I do it on B4i, there is no GetValuteAt Code: For i=0 To CityMap.Size-1 City = CityMap.GetValueAt(i) If City.CompareTo(Main.MYCity) = 0 Then Main.MyCityCode = CityMap.GetKeyAt (i) Log("Got City Code") i = CityMap.Size - 1 End If Next
Erel B4X founder Staff member Licensed User Longtime User Jan 26, 2015 #2 See this link: https://www.b4x.com/android/forum/threads/missing-function-map.46971/ Seems to me that you are not using the map correctly (or in the best way). If you need to look for a value then either switch the keys and values or use a second map that maps between the cities and the codes. However you can use this code: Code: For Each CityCode As String in CityMap.Keys Dim City As String = CityMap.Get(CityCode) If City.CompareTo(Main.MyCity) = 0 Then Main.MyCityCode = CityCode Exit End If Next Upvote 0
See this link: https://www.b4x.com/android/forum/threads/missing-function-map.46971/ Seems to me that you are not using the map correctly (or in the best way). If you need to look for a value then either switch the keys and values or use a second map that maps between the cities and the codes. However you can use this code: Code: For Each CityCode As String in CityMap.Keys Dim City As String = CityMap.Get(CityCode) If City.CompareTo(Main.MyCity) = 0 Then Main.MyCityCode = CityCode Exit End If Next