Control array object from form Controls collection?
How can I access a control array object as an item on a form, vs. explicitly by name?
e.g. I have a TextBox "Text1", with index=0 on a form (that's it)
but the following code fails with Error 344, "Must specify index for object array"
Code:
Dim xx As Object
For Each xx In Me.Controls
Load xx(1)
Next xx
FWIW
Load Text1(1) works fine.
? TypeName(Text1) = Object
? TypeName(xx) = TextBox
Apparently, in the For Each loop it's giving me actual instances of the textbox control, rather than the control array itself.
Thanks, DaveBo
Re: Control array object from form Controls collection?
Quote:
Originally posted by DaveBo
How can I access a control array object as an item on a form, vs. explicitly by name?
e.g. I have a TextBox "Text1", with index=0 on a form (that's it)
but the following code fails with Error 344, "Must specify index for object array"
Code:
Dim xx As Object
For Each xx In Me.Controls
Load xx(1)
Next xx
FWIW
Load Text1(1) works fine.
? TypeName(Text1) = Object
? TypeName(xx) = TextBox
Apparently, in the For Each loop it's giving me actual instances of the textbox control, rather than the control array itself.
Thanks, DaveBo
Modify ur code thus:
Dim xx As Object
For Each xx In Me.Controls
Load xx(1)
Next xx
Re: Re: Control array object from form Controls collection?
Quote:
Originally posted by apps_tech
Modify ur code thus:
Dim xx As Object
For Each xx In Me.Controls
Load xx(1)
Next xx
sorry before i enter the code it got submitted. here is the one i wanted to write:
Dim xx As Object
For Each xx In Me.Controls
If typeof(xx) is textbox then
Load xx(1)
end if
Next xx
i guess it should work...