Home All Groups Group Topic Archive Search About
Author
15 Apr 2005 3:32 AM
Daniel
Simple Question.  Why this simple code will not compile?
Dim obj As Object

For Each obj In GroupBox1



Next

Author
15 Apr 2005 3:58 AM
Adam Goossens
Hi,

You need to reference the Controls property of the GroupBox1 object:

---
For Each obj In GroupBox1.Controls
    ' etc...
Next
---

Regards,
-Adam.

Daniel wrote:
Show quoteHide quote
> Simple Question.  Why this simple code will not compile?
> Dim obj As Object
>
> For Each obj In GroupBox1
>
>
>
> Next
>
>
Author
15 Apr 2005 6:59 AM
Cor Ligthert
Daniel,

Because that you for a foreach needs to go through a collection(ilist
icollection)

A groupbox exist from individual properties, methods and events, however
those are not direct in a collection.

Cor
Author
15 Apr 2005 11:43 AM
Herfried K. Wagner [MVP]
"Daniel" <d_shl***@hotmail.com> schrieb:
> Simple Question.  Why this simple code will not compile?
> Dim obj As Object
>
> For Each obj In GroupBox1

Try this instead:

\\\
For Each ctr As Control In Me.GroupBox1.Controls
    ...
Next ctr
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
16 Apr 2005 2:46 AM
Daniel
Thanks, for your response.
I was looking, for some reason, for something like GroupBox1.Objects instead
of Controls :(
Thanks a lot.