looping in sstatb(2) and retrive the name of each controll

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

looping in sstatb(2) and retrive the name of each controll

Post by sal21 »

How to...
looping in sstatb(2) and retrive the type and name of each controll
In my case i have only label, tbox and combobox

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

Re: looping in sstatb(2) and retrive the name of each controll

Post by HansV »

Does this work?

Code: Select all

    Dim ctl As Control
    For Each ctl In Me.Controls
        If ctl.Container Is Me.SSTab2 Then
            Debug.Print TypeName(ctl), ctl.Name
        End If
    Next ctl
Best wishes,
Hans

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

Re: looping in sstatb(2) and retrive the name of each controll

Post by sal21 »

HansV wrote:
24 Dec 2024, 14:03
Does this work?

Code: Select all

    Dim ctl As Control
    For Each ctl In Me.Controls
        If ctl.Container Is Me.SSTab2 Then
            Debug.Print TypeName(ctl), ctl.Name
        End If
    Next ctl
Sorry....
i need to loop only the second tab o Sstab

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

Re: looping in sstatb(2) and retrive the name of each controll

Post by HansV »

Again untested:

Code: Select all

    Dim ctl As Control
    For Each ctl In Me.Controls
        If ctl.Container Is Me.SSTab2 Then
            If ctl.Container.Tab = 1 Then ' tabs are zero-based
                Debug.Print TypeName(ctl), ctl.Name
            End If
        End If
    Next ctl
Best wishes,
Hans

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

Re: looping in sstatb(2) and retrive the name of each controll

Post by sal21 »

HansV wrote:
24 Dec 2024, 15:11
Again untested:

Code: Select all

    Dim ctl As Control
    For Each ctl In Me.Controls
        If ctl.Container Is Me.SSTab2 Then
            If ctl.Container.Tab = 1 Then ' tabs are zero-based
                Debug.Print TypeName(ctl), ctl.Name
            End If
        End If
    Next ctl
I'll clarify...
in my project have a Sstab with 5 panel
I need to loop element of the second panel (number 1 in this case, you suggestion)

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

Re: looping in sstatb(2) and retrive the name of each controll

Post by HansV »

I don't have VB6 so I cannot help you.
Best wishes,
Hans

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

Re: looping in sstatb(2) and retrive the name of each controll

Post by sal21 »

HansV wrote:
24 Dec 2024, 16:26
I don't have VB6 so I cannot help you.
no prob.
tks in other case