Hi! I am trying to use a sub to list controls in a form. The form has controls on it as well as in a groupbox. I am doing this using a sub command
I have gotten it to list all the controls in the form as well as the groupbox, but searately. My book says that each control has a controls count property that tells wheather there are items inside the control. Thus, by checking that, my sub can recurse deeper into that control and get the names of the items in there. I cannot figure out how to do this??
Any help is appreciated! Here is a sample of the code that I have to get all teh items listed.
Sub ControlList()
Dim Ctrl As Control
Dim grpCtrl As Control
For Each Ctrl In Me.Controls
MsgBox("The controls are: " & Ctrl.Name)
Next Ctrl
For Each grpCtrl In GroupBox1.Controls
MsgBox("The grouped controls are: " & grpCtrl.Name)
Next grpCtrl
End Sub
I also forgot to add that I need the items to appear in a list in a messagebox. As you can see, right now they are just in their own messageboxes.
I have gotten it to list all the controls in the form as well as the groupbox, but searately. My book says that each control has a controls count property that tells wheather there are items inside the control. Thus, by checking that, my sub can recurse deeper into that control and get the names of the items in there. I cannot figure out how to do this??
Any help is appreciated! Here is a sample of the code that I have to get all teh items listed.
Sub ControlList()
Dim Ctrl As Control
Dim grpCtrl As Control
For Each Ctrl In Me.Controls
MsgBox("The controls are: " & Ctrl.Name)
Next Ctrl
For Each grpCtrl In GroupBox1.Controls
MsgBox("The grouped controls are: " & grpCtrl.Name)
Next grpCtrl
End Sub
I also forgot to add that I need the items to appear in a list in a messagebox. As you can see, right now they are just in their own messageboxes.
Last edited: