简体   繁体   中英

How do I iterate over an array when the array elements are controls?

I need to iterate over an array of control names to change their TabIndex values.

This is what I've tried:

Dim ctls As Variant
Dim i As Variant

ctls = Array("Text2")

For Each i In ctls
    i.TabIndex = 1
Next

...but this gives me the error: Error 424: Object Required . How do I make the array element be recognized as an object?

Dim ctrl As Control

For Each ctrl In Me.Controls

    ctrl.TabIndex = 1

Next

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM