I would like to be able to iterate through a collection of form objects based on their name. Alternatively, can you refer to a form object by a variable name?
For example, instead of:
Is it possible to do either of these:
The app I'm working on iterates through the same objects in several different places. I'm just trying to make the code more compact and have less typing.
For example, instead of:
B4X:
doSomething(txtField1.Text)
doSomething(txtField2.Text)
doSomething(txtField3.Text)
doSomething(txtField4.Text)
Is it possible to do either of these:
B4X:
#Option 1
for i = 1 to 4
doSomething("txtField" & i & ".Text")
next
#Option 2
Dim txtMap as Map
txtMap.Put("txtField1")
txtMap.Put("txtField2")
txtMap.Put("txtField3")
txtMap.Put("txtField4")
for i = 1 to 4
doSomething(niftyObjectSyntax(txtMap.Get(i)).Text)
Next
The app I'm working on iterates through the same objects in several different places. I'm just trying to make the code more compact and have less typing.