
Originally Posted by
getusama
Hi
Can anyone tell me how to change properties of ALL OBJECTS in a form during run-time in VB6?
ObjectName.
I just forgot how to do this. I just remember declaring a variable as OBJECT and using a LOOP.
for e.g. can you tell me how to change the VISIBLE property of all objects during runtime.
I know how to change it usign the object name like bellow so I'm not asking about that.
ObjectName.Visible = True
Looking forward to hear.
Thanks
Of course, not all objects have a visible property.
If you mean to say all controls on a form, you can loop through them with the me.controls collection. However, you'll want some sort of logic to handle controls that do not have a visible property or that you want to keep visible.
Here is a simplistic example:
VB Code:
Private Sub mnuHide_Click()
Dim c As Control
On Error Resume Next
For Each c In Me.Controls
If Not TypeOf c Is Menu Then
c.Visible = False
End If
Next c
End Sub
Private Sub mnuMakeVisible_Click()
Dim c As Control
For Each c In Me.Controls
If Not TypeOf c Is Menu Then
c.Visible = True
End If
Next c
End Sub