I am trying to use a collection to reference a control array. In the example below
Col(1).Top = DrawTop
would replace
F.MBIcon(ControlIndex).Top = DrawTop
It doesn't work. It sets the property on the wrong object, not at all or accesses a control array index that doesn't exist.
Is what I am trying to do possible? It would make my code more readable. Note that I would replace Col(1).Top with
something like FMB(Index(SubItemType)).Top in my final code.
I am aware of CallByName and that would help too in some parts of my code.
Cheers, Brent
Function MenuDrawSubItems(Area As String, Level As String, DrawLeft As Long, DrawTop As Long, ItemIndex As Long)
Dim col As New Collection
For s = 1 To MB.Item(ItemIndex).SubItemsCount
SubItemsType = MB.Item(ItemIndex).FSubItemsType(s)
ControlIndex = MB.Item(ItemIndex).FSubItemsIndex(s)
col.Add F.MBIcon(ControlIndex)
col.Add F.MBLabel(ControlIndex)
Select Case SubItemsType
Case "Icon"
col(1).Top = DrawTop
[more code]
End Function
Col(1).Top = DrawTop
would replace
F.MBIcon(ControlIndex).Top = DrawTop
It doesn't work. It sets the property on the wrong object, not at all or accesses a control array index that doesn't exist.
Is what I am trying to do possible? It would make my code more readable. Note that I would replace Col(1).Top with
something like FMB(Index(SubItemType)).Top in my final code.
I am aware of CallByName and that would help too in some parts of my code.
Cheers, Brent
Function MenuDrawSubItems(Area As String, Level As String, DrawLeft As Long, DrawTop As Long, ItemIndex As Long)
Dim col As New Collection
For s = 1 To MB.Item(ItemIndex).SubItemsCount
SubItemsType = MB.Item(ItemIndex).FSubItemsType(s)
ControlIndex = MB.Item(ItemIndex).FSubItemsIndex(s)
col.Add F.MBIcon(ControlIndex)
col.Add F.MBLabel(ControlIndex)
Select Case SubItemsType
Case "Icon"
col(1).Top = DrawTop
[more code]
End Function