looping all label in array

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

looping all label in array

Post by sal21 »

I have this array of labels named lpr, similar:

lpr(0)
lpr(1)
ecc...

how to loop all label in array on a form and retrieve the tag string?

User avatar
HansV
Administrator
Posts: 75751
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: looping all label in array

Post by HansV »

You can use

Code: Select all

    Dim i As Long
    For i = lpr.LBound To lpr.UBound
        Debug.Print lpr(i).Tag
    Next i
or

Code: Select all

    Dim itm As Label
    For Each itm In lpr
        Debug.Print itm.Tag
    Next itm
Regards,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: looping all label in array

Post by sal21 »

HansV wrote:
06 Nov 2022, 12:35
You can use

Code: Select all

    Dim i As Long
    For i = lpr.LBound To lpr.UBound
        Debug.Print lpr(i).Tag
    Next i
or

Code: Select all

    Dim itm As Label
    For Each itm In lpr
        Debug.Print itm.Tag
    Next itm
:clapping: