Load Object

If I have on my form an array object called: Frame1() [a frame object], I can create multiple copies of that frame with the
code Load Frame1(x).  If there are objects inside that frame1(), they are not created when I load another frame1() with the code Load Frame1(x).
How can I load additional copies of Frame1(x) that loads the objects that are inside frame1().  The frame1() contains some labels.



dastaubAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
(assuming all controls in Frame1 are also control arrays)

Private Sub Command1_Click()
    Dim index As Integer
    index = Frame1.Count
    Load Frame1(index)
    Frame1(index).Left = Frame1(0).Left + (Frame1(0).Width * index)
    Frame1(index).Visible = True
   
    Dim c As Control
    Dim c2 As Control
    For Each c In Me.Controls
        If c.Container Is Frame1(0) Then
            Load Me.Controls(c.Name)(index)
            Set c2 = Me.Controls(c.Name)(index)
            Set c2.Container = Frame1(index)
            c2.Left = Me.Controls(c.Name)(0).Left
            c2.Top = Me.Controls(c.Name)(0).Top
            c2.Visible = True
        End If
    Next
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dastaubAuthor Commented:
Idle_mind,
I copy and pasted your code and it works perfectly.  Could I ask you give a short description of what is going on in the code?  I am struggling to follow it.
Thank You.

 For Each c In Me.Controls
        If c.Container Is Frame1(0) Then
            Load Me.Controls(c.Name)(index)
            Set c2 = Me.Controls(c.Name)(index)
            Set c2.Container = Frame1(index)
            c2.Left = Me.Controls(c.Name)(0).Left
            c2.Top = Me.Controls(c.Name)(0).Top
            c2.Visible = True
        End If
    Next
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
Not sure my explanantion helps...

    Dim c As Control
    Dim c2 As Control
    For Each c In Me.Controls                              ' Iterate thru EVERY control on the form
        If c.Container Is Frame1(0) Then               ' If this control is contained by the First Frame in Frame1()
            Load Me.Controls(c.Name)(index)          ' Load another one of this control
            Set c2 = Me.Controls(c.Name)(index)     ' Make "c2" point to this newly loaded control
            Set c2.Container = Frame1(index)          ' Make the Container or c2 the newly load Frame
            c2.Left = Me.Controls(c.Name)(0).Left    ' Make the Left of c2 the same as the Left of the First control in this control array
            c2.Top = Me.Controls(c.Name)(0).Top    ' Make the Top of c2 the same as the Top of the First control in this control array
            c2.Visible = True                                   ' Make c2 Visible
        End If
    Next
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.