MegatenFreak Active Member Licensed User Nov 28, 2021 #1 Hi. I'm trying to clean up my code. One of the annoying things is that It is full of places where I initialize a large number (for example, 30) lists at once. Something like: Code: Copy Dim a, b, c, d as List a.Initialize b.Initialize c.Initialize d.Initialize I was wondering if there is a "cleaner" way to do this. I tried the following: Code: Copy For Each x As List in Array(a, b, c, d) x.Initialize Next It didn't work. The code runs, but I get an exception saying the lists are not initialized. Any ideas?
Hi. I'm trying to clean up my code. One of the annoying things is that It is full of places where I initialize a large number (for example, 30) lists at once. Something like: Code: Copy Dim a, b, c, d as List a.Initialize b.Initialize c.Initialize d.Initialize I was wondering if there is a "cleaner" way to do this. I tried the following: Code: Copy For Each x As List in Array(a, b, c, d) x.Initialize Next It didn't work. The code runs, but I get an exception saying the lists are not initialized. Any ideas?
Erel B4X founder Staff member Licensed User Longtime User Nov 28, 2021 #2 This will work: Code: Copy For Each x As List in Array As List(a, b, c, d) However if you have multiple similar lists then you should probably switch to a single list with custom types. Upvote 0
This will work: Code: Copy For Each x As List in Array As List(a, b, c, d) However if you have multiple similar lists then you should probably switch to a single list with custom types.
MegatenFreak Active Member Licensed User Nov 28, 2021 #3 Erel said: This will work: Code: Copy For Each x As List in Array As List(a, b, c, d) However if you have multiple similar lists then you should probably switch to a single list with custom types. Click to expand... Thanks. It worked perfectly. Actually, the lists hold information loaded from a database table. Each list holds the value of a specific column in all the records. I suppose it would have been a lot better if I had used custom types. Upvote 0
Erel said: This will work: Code: Copy For Each x As List in Array As List(a, b, c, d) However if you have multiple similar lists then you should probably switch to a single list with custom types. Click to expand... Thanks. It worked perfectly. Actually, the lists hold information loaded from a database table. Each list holds the value of a specific column in all the records. I suppose it would have been a lot better if I had used custom types.