Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleInitialize the controls on a new MDI child form by copying them from an existing form
DescriptionThis example shows how to initialize the controls on a new MDI child form by copying them from an existing form in Visual Basic 6. It loops through the controls on the active form, copying their values into the new form.
KeywordsMDI, MDI child, initialize
CategoriesControls, Tips and Tricks
 
In the form's Load event handler, the program looks through the Controls collections of the new form and the ActiveForm, copying the values from the active form into the new controls.
 
Private Sub Form_Load()
Dim i As Integer

    If MDIForm1.ActiveForm Is Nothing Then Exit Sub

    For i = 0 To Controls.Count - 1
        Select Case TypeName(Controls(i))
            Case "TextBox"
                Controls(i).Text = _
                    MDIForm1.ActiveForm.Controls(i).Text
            Case "Label"
                Controls(i).Caption = _
                    MDIForm1.ActiveForm.Controls(i).Caption
        End Select
    Next i
End Sub
 
This version copies only TextBoxes and Labels, but you could modify it to copy values into other types of controls.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated