CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002
    Posts
    41

    For each Ctl in xxxx, why doesn't this wok

    I am trying to loop thru all the controls that are in a groupbox. Here is what I am trying. This is my test code for debuggin.

    Dim ctl as Control
    Dim x as integer

    x=form1.instance.GroupBox2.Controls.Count()

    For Each ctl in Form1.instance.GroupBox2.Controls
    myname=ctl.name
    next

    x reports back 76
    So I would expect the for loop to loop 76 times. It only loops once.

    Why is this? I don't know if this helps. But the GroupBox2 is actually on a TabPage also.

    Thanks

  2. #2
    Join Date
    Oct 2002
    Location
    Växjö, Sweden
    Posts
    225
    I just can't seem to replicate your problem,

    Dim con As Control
    Dim a As Integer
    For Each con In Me.GroupBox2.Controls
    a += 1
    Next
    MsgBox(a)

    I have a groupbox2 on a tabpage with one checkbox, one radiobutton and one button, the MsgBox reports back 3.

    Have I got something wrong (am I missing something with the instance thing, why do you need that?)

    /Leyan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured