Bug in List with User defined type

touchsquid

Active Member
Licensed User
Longtime User
If I add elements to a list which are user defined types, all the elements in the list are the same, although the added code was different.

The user defined Type is:
Type DeviceProfile (Brand As String, _
TypeName As String, _
BrandID As Int, _
Model As String, _
TypeID As Int, _
DeviceID As Int, _
TVinput As Int)

If I add a single string to the list, instead of a Typed variable, it works correctly.

Is this a known bug? If not I can probably create an example for testing.
 
Make sure that you are not reusing the same single object when you are adding the items.
Objects are never being copied implicitly.
The correct way to add many objects of a certain type is:
Code: Copy
For i = 0 To 100
 Dim mt As MyType
 mt.Initialize
 mt... = ...
 mt... = ...
 List1.Add(mt)
Next
A new object is created each iteration.
 
My mistake was Dim X as Deviceprofile outside the loop. Your version corrects the problem. As always, great help and support!
 
Back
Top