TungVan
asked on
collection and objects
hi,
I have a collection variable: Private mControlCollection As VBA.Collection
What I store in that collection is CButton and CLabel objects. For example,
--------------------------
Set oButton = New CButton
oButton.ButtonType = "Formal"
oButton.CControl_ControlLa
oButton.CControl_PositionX
oButton.CControl_PositionY
oButton.CControl_Width = 125
oButton.CControl_Height = 45
oButton.CControl_Hidden = False
mControlCollection.Add oButton
Set oButton = Nothing
Set oLabel = New CLabel
oLabel.LabelType = "Formal"
oLabel.CControl_ControlLab
oLabel.CControl_PositionX = 200
oLabel.CControl_PositionY = 100
oLabel.CControl_Width = 125
oLabel.CControl_Height = 25
oLabel.CControl_Hidden = False
mControlCollection.Add oLabel
Set oLabel = Nothing
--------------------------
So oButton instance is stored in index 0, oLabel is stored in index 1, etc...
Later on, when I need to access object in mControlCollection, how do I know if this object is of type CButton or CLabel?
Is there a way to know it?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or something like...
Dim c As Control
For Each c In mControlCollection
Select Case TypeName(c)
Case "Label"
Case "CommandButton"
Case "TextBox"
' etc....
End Select
Next c
Dim c As Control
For Each c In mControlCollection
Select Case TypeName(c)
Case "Label"
Case "CommandButton"
Case "TextBox"
' etc....
End Select
Next c
ASKER
thx..it works