I have a program that use a Map to load some values. At some point, I want to load some of the map values into a combobox.
For simplicity I have grouped my data in my map in group of 10 data for each group. Some are not used and reserved for future feature. So to retieve my data I simply divide the total size of the map by ten and add the index of the desired value. From a For loop I was supposed to be able to retrieve data of each group at a given index. But it seems not to work.
I have made a minimal code (this is not the original code but it show the issue).
Running this code in debug mode with a breakpoint at the end the For loop demonstrate the problem.
The ComboBox was created with the internal designer.
The first time the index is 3 and the return value is "Group0 Item3" as expected.
But the second time, while the index is 13 (good) it return "Group1 Item6" which is at index 16.
Thank you for any help.
For simplicity I have grouped my data in my map in group of 10 data for each group. Some are not used and reserved for future feature. So to retieve my data I simply divide the total size of the map by ten and add the index of the desired value. From a For loop I was supposed to be able to retrieve data of each group at a given index. But it seems not to work.
I have made a minimal code (this is not the original code but it show the issue).
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private ComboBox1 As ComboBox
Private MyMap, TempMap As Map
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("main") 'Load the layout file.
MainForm.Show
MyMap.Initialize
MyMap = FillMap
Private x, maxx, index As Int
Private str_item As String
ComboBox1.Items.Clear
maxx = MyMap.Size / 10
For x = 0 To maxx
index = (x * 10) + 3
str_item = MyMap.GetValueAt(index)
ComboBox1.Items.Add(str_item)
Next
End Sub
Sub FillMap As Map
TempMap.Initialize
TempMap.Clear
'Group #0
TempMap.Put(0,"Group0 Item0")
TempMap.Put(1,"")
TempMap.Put(2,"Group0 Item2")
TempMap.Put(3,"Group0 Item3")
TempMap.Put(4,"Group0 Item4")
TempMap.Put(5,"Group0 Item5")
TempMap.Put(6,"Group0 Item6")
'Group #1
TempMap.Put(10,"Group1 Item0")
TempMap.Put(11,"")
TempMap.Put(12,"Group1 Item2")
TempMap.Put(13,"Group1 Item3")
TempMap.Put(14,"Group1 Item4")
TempMap.Put(15,"Group1 Item5")
TempMap.Put(16,"Group1 Item6")
'Group #x etc...
Return TempMap
End Sub
The ComboBox was created with the internal designer.
The first time the index is 3 and the return value is "Group0 Item3" as expected.
But the second time, while the index is 13 (good) it return "Group1 Item6" which is at index 16.
Thank you for any help.