S ST500 Active Member Licensed User Dec 12, 2018 #1 Hello, I have some arrays, they I'm adding with a For Loop in to a list. How can I create a sum of all arrays? Thanks for your help Martin
Hello, I have some arrays, they I'm adding with a For Loop in to a list. How can I create a sum of all arrays? Thanks for your help Martin
DonManfred Expert Licensed User Longtime User Dec 12, 2018 #2 Iterate through the list and all of their arrays and build a sum for all values. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Dec 12, 2018 #3 B4X: Dim list As List = Array(Array As Int(1, 2, 3), Array As Int(4, 5, 6)) Dim sum As Int For Each arr() As Int In list For Each i As Int In arr sum = sum + i Next Next Log(sum) Upvote 0
B4X: Dim list As List = Array(Array As Int(1, 2, 3), Array As Int(4, 5, 6)) Dim sum As Int For Each arr() As Int In list For Each i As Int In arr sum = sum + i Next Next Log(sum)