From: KC on
I have this multipage userform, containing 16 listboxes in 16 pages.
page0 has no listbox.
Whenever an item is selected in one of these listboxes, some 30 lines of
code is needed to process that item.
The original code thus contained 16 x 30 lines of code.

It took me 2 years on and off to construct a loop to do the same stuff, in
about 40 lines of code.
It turns out that each list box is not a list box, it is a control.
Its position has nothing to do with page number, which in turn is
multipage.value

Amazing


From: Bob Phillips on
A listbox is a listbox, a control is a more generic term for the controls on
a form. So a listbox is a listbox, a textbox is a textbox, but both are also
controls.

You can test the controls collection for the control type


For Each ctl In Me.Controls
Select Case TypeName(ctl)
Case "CommandButton": MsgBox ctl.Caption
Select Case TypeName(ctl)
Case "TextBox": MsgBox ctl.Value
Select Case TypeName(ctl)
Case "Label": MsgBox ctl.Caption
'etc.
Next


--

HTH

Bob

"KC" <pynasocas(a)yahoo.com.sg> wrote in message
news:eaY3X4w0KHA.4204(a)TK2MSFTNGP04.phx.gbl...
>I have this multipage userform, containing 16 listboxes in 16 pages.
> page0 has no listbox.
> Whenever an item is selected in one of these listboxes, some 30 lines of
> code is needed to process that item.
> The original code thus contained 16 x 30 lines of code.
>
> It took me 2 years on and off to construct a loop to do the same stuff, in
> about 40 lines of code.
> It turns out that each list box is not a list box, it is a control.
> Its position has nothing to do with page number, which in turn is
> multipage.value
>
> Amazing
>


From: KC on
I agree.
I have read similar examples many times in the past.
They all led me elsewhere.
Today when I read this again, I know where I have misunderstood it.

"Bob Phillips" <bob.phillips(a)somewhere.com> wrote in message
news:uQC5oQx0KHA.776(a)TK2MSFTNGP04.phx.gbl...
>A listbox is a listbox, a control is a more generic term for the controls
>on a form. So a listbox is a listbox, a textbox is a textbox, but both are
>also controls.
>
> You can test the controls collection for the control type
>
>
> For Each ctl In Me.Controls
> Select Case TypeName(ctl)
> Case "CommandButton": MsgBox ctl.Caption
> Select Case TypeName(ctl)
> Case "TextBox": MsgBox ctl.Value
> Select Case TypeName(ctl)
> Case "Label": MsgBox ctl.Caption
> 'etc.
> Next
>
>
> --
>
> HTH
>
> Bob
>
> "KC" <pynasocas(a)yahoo.com.sg> wrote in message
> news:eaY3X4w0KHA.4204(a)TK2MSFTNGP04.phx.gbl...
>>I have this multipage userform, containing 16 listboxes in 16 pages.
>> page0 has no listbox.
>> Whenever an item is selected in one of these listboxes, some 30 lines of
>> code is needed to process that item.
>> The original code thus contained 16 x 30 lines of code.
>>
>> It took me 2 years on and off to construct a loop to do the same stuff,
>> in about 40 lines of code.
>> It turns out that each list box is not a list box, it is a control.
>> Its position has nothing to do with page number, which in turn is
>> multipage.value
>>
>> Amazing
>>
>
>

From: Bob Phillips on
That's because I explain it so well <BG>

--

HTH

Bob

"KC" <pynasocas(a)yahoo.com.sg> wrote in message
news:%23ai%23Vjx0KHA.260(a)TK2MSFTNGP05.phx.gbl...
>I agree.
> I have read similar examples many times in the past.
> They all led me elsewhere.
> Today when I read this again, I know where I have misunderstood it.
>
> "Bob Phillips" <bob.phillips(a)somewhere.com> wrote in message
> news:uQC5oQx0KHA.776(a)TK2MSFTNGP04.phx.gbl...
>>A listbox is a listbox, a control is a more generic term for the controls
>>on a form. So a listbox is a listbox, a textbox is a textbox, but both are
>>also controls.
>>
>> You can test the controls collection for the control type
>>
>>
>> For Each ctl In Me.Controls
>> Select Case TypeName(ctl)
>> Case "CommandButton": MsgBox ctl.Caption
>> Select Case TypeName(ctl)
>> Case "TextBox": MsgBox ctl.Value
>> Select Case TypeName(ctl)
>> Case "Label": MsgBox ctl.Caption
>> 'etc.
>> Next
>>
>>
>> --
>>
>> HTH
>>
>> Bob
>>
>> "KC" <pynasocas(a)yahoo.com.sg> wrote in message
>> news:eaY3X4w0KHA.4204(a)TK2MSFTNGP04.phx.gbl...
>>>I have this multipage userform, containing 16 listboxes in 16 pages.
>>> page0 has no listbox.
>>> Whenever an item is selected in one of these listboxes, some 30 lines of
>>> code is needed to process that item.
>>> The original code thus contained 16 x 30 lines of code.
>>>
>>> It took me 2 years on and off to construct a loop to do the same stuff,
>>> in about 40 lines of code.
>>> It turns out that each list box is not a list box, it is a control.
>>> Its position has nothing to do with page number, which in turn is
>>> multipage.value
>>>
>>> Amazing
>>>
>>
>>
>


From: JLatham on
All Dalmations are dogs, but not all dogs are Dalmations.

"Bob Phillips" wrote:

> That's because I explain it so well <BG>
>
> --
>
> HTH
>
> Bob
>
> "KC" <pynasocas(a)yahoo.com.sg> wrote in message
> news:%23ai%23Vjx0KHA.260(a)TK2MSFTNGP05.phx.gbl...
> >I agree.
> > I have read similar examples many times in the past.
> > They all led me elsewhere.
> > Today when I read this again, I know where I have misunderstood it.
> >
> > "Bob Phillips" <bob.phillips(a)somewhere.com> wrote in message
> > news:uQC5oQx0KHA.776(a)TK2MSFTNGP04.phx.gbl...
> >>A listbox is a listbox, a control is a more generic term for the controls
> >>on a form. So a listbox is a listbox, a textbox is a textbox, but both are
> >>also controls.
> >>
> >> You can test the controls collection for the control type
> >>
> >>
> >> For Each ctl In Me.Controls
> >> Select Case TypeName(ctl)
> >> Case "CommandButton": MsgBox ctl.Caption
> >> Select Case TypeName(ctl)
> >> Case "TextBox": MsgBox ctl.Value
> >> Select Case TypeName(ctl)
> >> Case "Label": MsgBox ctl.Caption
> >> 'etc.
> >> Next
> >>
> >>
> >> --
> >>
> >> HTH
> >>
> >> Bob
> >>
> >> "KC" <pynasocas(a)yahoo.com.sg> wrote in message
> >> news:eaY3X4w0KHA.4204(a)TK2MSFTNGP04.phx.gbl...
> >>>I have this multipage userform, containing 16 listboxes in 16 pages.
> >>> page0 has no listbox.
> >>> Whenever an item is selected in one of these listboxes, some 30 lines of
> >>> code is needed to process that item.
> >>> The original code thus contained 16 x 30 lines of code.
> >>>
> >>> It took me 2 years on and off to construct a loop to do the same stuff,
> >>> in about 40 lines of code.
> >>> It turns out that each list box is not a list box, it is a control.
> >>> Its position has nothing to do with page number, which in turn is
> >>> multipage.value
> >>>
> >>> Amazing
> >>>
> >>
> >>
> >
>
>
> .
>
 |  Next  |  Last
Pages: 1 2
Prev: Application.UserName
Next: Random Running of a Script?