Link to home
Start Free TrialLog in
Avatar of TungVan
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_ControlLabel = "Admin"
    oButton.CControl_PositionX = 100
    oButton.CControl_PositionY = 100
    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_ControlLabel = "Clock"
  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
Avatar of rettiseert
rettiseert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TungVan
TungVan

ASKER



thx..it works
Avatar of Mike Tomlinson
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