P Penko Active Member Licensed User Longtime User Mar 20, 2012 #1 Hello! Why is there difference when I declare this way: B4X: Dim theList as List :theList.Initialize For i = 0 To thedata.Size - 1 Dim thisTest As Tests thisTest = thedata.Get(i) theList.Add(thisTest) Next versus: B4X: Dim thisTest as Tests above the For loop? I also tried thisTest.Initialize at the beginning of the loop but it didn't help either. With the faulty snippet I get basically 4 identical items !?
Hello! Why is there difference when I declare this way: B4X: Dim theList as List :theList.Initialize For i = 0 To thedata.Size - 1 Dim thisTest As Tests thisTest = thedata.Get(i) theList.Add(thisTest) Next versus: B4X: Dim thisTest as Tests above the For loop? I also tried thisTest.Initialize at the beginning of the loop but it didn't help either. With the faulty snippet I get basically 4 identical items !?
thedesolatesoul Expert Licensed User Longtime User Mar 20, 2012 #2 B4X: Dim thisTests as Tests will create a new object. Otherwise you are assigning the value to a previous reference (as it is not recreated). Upvote 0
B4X: Dim thisTests as Tests will create a new object. Otherwise you are assigning the value to a previous reference (as it is not recreated).
P Penko Active Member Licensed User Longtime User Mar 20, 2012 #3 I've persuaded myself I should Dim the object inside the For loop. How I detected it - the Click() event on the panels always highlighted the last panel. That's pretty unusual and made me integrate all variables inside the For loop. Upvote 0
I've persuaded myself I should Dim the object inside the For loop. How I detected it - the Click() event on the panels always highlighted the last panel. That's pretty unusual and made me integrate all variables inside the For loop.
thedesolatesoul Expert Licensed User Longtime User Mar 20, 2012 #4 Yes, I had the same problem and kickaha answered me in this same forum For reference: http://www.b4x.com/forum/basic4andr...ariables-objects-basic4android.html#post46951 Upvote 0
Yes, I had the same problem and kickaha answered me in this same forum For reference: http://www.b4x.com/forum/basic4andr...ariables-objects-basic4android.html#post46951
P Penko Active Member Licensed User Longtime User Mar 20, 2012 #5 I've read his topic but this one is hidden in a word or two and hasn't attracted my attention. Thank you for your help! Upvote 0
I've read his topic but this one is hidden in a word or two and hasn't attracted my attention. Thank you for your help!