|
|
Title | Initialize the controls on a new MDI child form by copying them from an existing form |
Description | This 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. |
Keywords | MDI, MDI child, initialize |
Categories | Controls, 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.
|
|
|
|
|
|