I made three controls, a Peg, a Pegboard, and a Solution. There is a control array of Pegs on the Pegboard, and one Pegboard on the Solution. Now, my form has a Solution on it, and it needs to be able to access properties of the pegs. I did this by putting the following function in the pegboard control:

Code:
‘This is in PegBoard
Public Function GetPeg(i As Integer) As Peg
    If i > m_numOfPegs Then
        MsgBox "Error: invalid peg: " & i
        Exit Function
    End If
    
    Set GetPeg = Peg(i)
End Function
I can get this to work in my code for Solution easily:

Code:
       ‘This line in Solution works fine
        PegBoard.GetPeg(i).ShowColor (False)
I want the form to be oblivious of the fact that there’s an extra level of abstraction (the Pegboard). So I created a GetPeg function for the Solution control:
Code:
‘This is in Solution
Public Function GetPeg(Index As Integer) As Peg
    Set GetPeg = PegBoard.GetPeg(Index)
End Function
And want to directly access a peg from the solution like this:
Code:
‘This is in Form
   Dim p As Peg

    Set p = Solution.GetPeg(i)
But this causes an runtime error ‘13’ type mis-match. It seems that my mult-leveling is causing problems. Does anyone know if what I’m trying to do is possible? I guess I could expose my pegboard and use Solution.GetPegboard.GetPeg(i), but that’s clunky, and I would prefer not to do it that way.

Thanks.