-
Re: Newbie: "For Each with variable" Question
This will change the visibility of all command buttons;
Dim objCtrl As Control
For Each objCtrl In Me.Controls
If TypeOf objCtrl Is CommandButton Then
objCtrl.Visible = False
End If
Next
--
Veign
www.veign.com
Code Samples & Sample Projects
http://www.veign.com/information/app.../info_app.html
Submit Your Best Code (you keep the rights)
http://www.veign.com/information/app...de_submit.html
---------
"Magic" <magic1521@hotmail.com> wrote in message news:3ccea9f4@10.1.10.29...
>
> Is there a way to use the following For Each with a variable?
> IOW, ( See_Controls "CommandButton", True ),
> to see all command buttons and ( See_Controls "CommandButton", False ),
> To make all copmmand buttons invisiable?
>
> This does not work!
> I've tried every combination I could think of!
>
> Private Sub See_All_Controls(Obj_Ctrl As Control, x As String)
>
> Dim vControl
>
> ' make Controls on form visible/invisible.
> For Each vControl In Me.Controls ' where Me is the form
> If TypeOf vControl Is Obj_Ctrl Then
> vControl.Visible = x
> End If
> Next
>
> End Sub
>
> Thanks,
>
> Magic
-
Newbie: "For Each with variable" Question
Is there a way to use the following For Each with a variable?
IOW, ( See_Controls "CommandButton", True ),
to see all command buttons and ( See_Controls "CommandButton", False ),
To make all copmmand buttons invisiable?
This does not work!
I've tried every combination I could think of!
Private Sub See_All_Controls(Obj_Ctrl As Control, x As String)
Dim vControl
' make Controls on form visible/invisible.
For Each vControl In Me.Controls ' where Me is the form
If TypeOf vControl Is Obj_Ctrl Then
vControl.Visible = x
End If
Next
End Sub
Thanks,
Magic
-
Re: Newbie: "For Each with variable" Question
Here's a slight mod to your code... works fine
'==========
Option Explicit
Private Sub Form_Click()
Call See_All_Controls(Command1, True)
End Sub
Private Sub Command1_Click()
Call See_All_Controls(Command1, False)
End Sub
Private Sub See_All_Controls(Obj_Ctrl As Control, x As Boolean)
Dim vControl As Control
' make Controls on form visible/invisible.
For Each vControl In Me.Controls ' where Me is the form
If TypeName(vControl) = TypeName(Obj_Ctrl) Then
vControl.Visible = x
End If
Next
End Sub
'==========
--
Ken Halter
MS-MVP-VB
http://www.vbsight.com/
Please keep it in the groups..
Magic wrote:
> Is there a way to use the following For Each with a variable?
> IOW, ( See_Controls "CommandButton", True ),
> to see all command buttons and ( See_Controls "CommandButton", False
> ), To make all copmmand buttons invisiable?
>
> This does not work!
> I've tried every combination I could think of!
>
> Private Sub See_All_Controls(Obj_Ctrl As Control, x As String)
>
> Dim vControl
>
> ' make Controls on form visible/invisible.
> For Each vControl In Me.Controls ' where Me is the form
> If TypeOf vControl Is Obj_Ctrl Then
> vControl.Visible = x
> End If
> Next
>
> End Sub
>
> Thanks,
>
> Magic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|