I am running the code analogous to the following:
The idea is to add a couple of elements to a list.
The code adds the elements as reference. This means that every element is identical and you get a list filled with:
GroupOfElements
[0] Element.ID = 4; Element.TextField = "Element 4"
[1] Element.ID = 4; Element.TextField = "Element 4"
[2] Element.ID = 4; Element.TextField = "Element 4"
[3] Element.ID = 4; Element.TextField = "Element 4"
[4] Element.ID = 4; Element.TextField = "Element 4"
Is there any way I can add the elements by value instead of reference?
B4X:
GroupOfElements As List
For n = 0 To 4
Element.Initialize
Element.ID = n
Element.TextField = "Element " + n
GroupOfElements.Add(Element)
Next
The idea is to add a couple of elements to a list.
The code adds the elements as reference. This means that every element is identical and you get a list filled with:
GroupOfElements
[0] Element.ID = 4; Element.TextField = "Element 4"
[1] Element.ID = 4; Element.TextField = "Element 4"
[2] Element.ID = 4; Element.TextField = "Element 4"
[3] Element.ID = 4; Element.TextField = "Element 4"
[4] Element.ID = 4; Element.TextField = "Element 4"
Is there any way I can add the elements by value instead of reference?