S Smee Well-Known Member Licensed User Longtime User Apr 15, 2013 #1 i have a collection of text boxes. How do i use a for each to adjust the property(s) of them all. in fact for any control sorry i mean view. is there already a thread on this? i could not find any when searching
i have a collection of text boxes. How do i use a for each to adjust the property(s) of them all. in fact for any control sorry i mean view. is there already a thread on this? i could not find any when searching
Erel B4X founder Staff member Licensed User Longtime User Apr 15, 2013 #2 i have a collection of text boxes Click to expand... Which type of collection? Upvote 0
S Smee Well-Known Member Licensed User Longtime User Apr 16, 2013 #3 Sorry Erel, I should have said i have several edit text boxes. i want to set properties etc in a for each group. in vb similar was Code: Copy For each control in form if control=textbox then end if next I would also be checking that each text box has been filled in. Last edited: Apr 16, 2013 Upvote 0
Sorry Erel, I should have said i have several edit text boxes. i want to set properties etc in a for each group. in vb similar was Code: Copy For each control in form if control=textbox then end if next I would also be checking that each text box has been filled in.
grant1842 Active Member Licensed User Longtime User Apr 16, 2013 #4 Are you storing the editboxes in an array? Upvote 0
S Smee Well-Known Member Licensed User Longtime User Apr 16, 2013 #5 hi Grant, No. if i do that i would not really need to use For Each. The structure of a traditional For Each is that each control/view can be addressed based on its type not its name. Thanks for the reply Upvote 0
hi Grant, No. if i do that i would not really need to use For Each. The structure of a traditional For Each is that each control/view can be addressed based on its type not its name. Thanks for the reply
stevel05 Expert Licensed User Longtime User Apr 16, 2013 #6 You can do: Code: Copy For i = 0 To Activity.NumberOfViews-1 If Activity.GetView(i) Is EditText Then Dim ET As EditText = Activity.GetView(i) Log(i&" "&ET.Text) 'And anything else End If Next If the EditTexts are on a Panel, change Activity for PanelName. Upvote 0
You can do: Code: Copy For i = 0 To Activity.NumberOfViews-1 If Activity.GetView(i) Is EditText Then Dim ET As EditText = Activity.GetView(i) Log(i&" "&ET.Text) 'And anything else End If Next If the EditTexts are on a Panel, change Activity for PanelName.
grant1842 Active Member Licensed User Longtime User Apr 16, 2013 #7 All a for each loop does is iterate through a list/array of objects, returning an object of your type cast for each object. With that being said, you need a list/array to iterate through. For me, if you're not wanting to use an array or list, then you could put the edits on a panel and loop through them that way. EDIT: Looks like steve beat me to the punch Upvote 0
All a for each loop does is iterate through a list/array of objects, returning an object of your type cast for each object. With that being said, you need a list/array to iterate through. For me, if you're not wanting to use an array or list, then you could put the edits on a panel and loop through them that way. EDIT: Looks like steve beat me to the punch
S Smee Well-Known Member Licensed User Longtime User Apr 16, 2013 #8 Steve\Grant Thanks guys, thats exactly what i need. Cheers Upvote 0