Public Sub EnableFrame(InFrame As Frame, ByVal Flag As
Boolean)
Dim Contrl As Control
'some controls don't have the Container.Name property,
so instead of
'stopping the application with an error message, we ignore
them.
On Error Resume Next
'enable or disable the frame that passed as
parameter.
InFrame.Enabled = Flag
'passing over all controls
For Each
Contrl In InFrame.Parent.Controls
'if the control is
found in the frame
If
(Contrl.Container.Name = InFrame.Name) Then
'if the
control is a frame, and it's not the frame that passed as parameter,
i.e.
'other frame that found inside our frame, recursively run this sub with
this frame,
'to enable or disable all the controls in
it.
If (TypeOf
Contrl Is Frame) And Not (Contrl.Name = InFrame.Name)
Then
EnableFrame Contrl, Flag
Else
'enable or disable the control
If Not (TypeOf Contrl Is Menu) Then Contrl.Enabled =
Flag
End
If
End If
Next
End Sub
Private Sub Command1_Click()
EnableFrame Frame1, False
End Sub
Private Sub Command2_Click()
EnableFrame Frame1,
True
End Sub