Situation:
a) I have a simple file "statuses.csv" that contains the following:
B4X:
01-general
02-ugarte Centro
03-ugarte Rural
b) I want to load it to a ComboBox
Try the following but it doesn't work:
B4X:
Dim su As StringUtils
Dim codTe As List = su.LoadCSV(Main.pRutaBase, "estados.csv", ",")
Log("Tamaño Archivo codte: " & codTe.Size)
Log("Item 0: " & codTe.Get(0))
For i = 0 To codTe.Size -1
B4XComboBox1.cmbBox.Add(codTe.Get(i))
Log("Item: " & i & " --->" & codTe.Get(i))
Next
When you load a list using StringUtils, each item is a string array. Your code could have worked this way:
B4X:
Dim su As StringUtils
Dim codTe As List = su.LoadCSV(Main.pRutaBase, "estados.csv", ",")
For Each line() As String In codTe
B4XComboBox1.cmbBox.Add(line(0))
Next
Excellent @Mahares !!!
It worked the same way!
Now I have understood that "StringUtils", returns an array for each row / line of the CSV file. In my case, each row has only one field, and therefore you indicate "line (0)". Thanks for teaching me!.
NOTE: I have a "special" file where I am saving valuable source code. These two ways to load a ComboBox go there!