michael_krell
asked on
Visual Basic 2005. processing Objects in a Control Collection
I am trying to make a sub function that hides all of a specified object on a form. I am trying to hide labels currently. I wrote the code fairly simply, but i cant seem to find a property inside of the Control object where a certain object can be distinguished.
Can someone tell me what property in the Control data type can be used to distinguish what the object is? "for example: text box, label, etc....."
Thanks
Can someone tell me what property in the Control data type can be used to distinguish what the object is? "for example: text box, label, etc....."
Thanks
Public Sub HideShowlabels(ByVal Visible As Boolean)
Dim CtrlVar As Control
If Visible Then
For Each CtrlVar In Controls
CtrlVar.Visible = True
Next
Else
For Each CtrlVar In Controls
CtrlVar.Visible = False
Next
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Had to change the code slightly to get it to work.
You could simplify that to:
Public Sub HideShowlabels(ByVal VisibleState As Boolean)
For Each CtrlVar As Control In Me.Controls
If TypeOf CtrlVar Is Label Then
CtrlVar.Visible = VisibleState
End If
Next
End Sub
ASKER
Open in new window