Expert Needed, RE: Forms;Controls:Loops

rallan
09-05-2000, 03:24 PM
Using the For Each loop.
I need to change the property of a control on any form. But only a certin type of control.

For exapmle I want to change all captions for command buttons to "ZZZ". If I do it by "FOR EACH Control in FORM1" all my label's would also change to "ZZZ". I don't want to do that

sunil
09-05-2000, 04:34 PM
Hi,

You can try doing it by using the TypeName function.
Inside your for loop code write a if statement to check the TypeOf Control. The function is used like this
TypeName(Controls(i))
where i is the index of the control. You can use this to check the type of the current control in your loop and then perform the required property change.

Thanks,
Sunil

sunil
09-05-2000, 04:34 PM
Hi,

You can try doing it by using the TypeName function.
Inside your for loop code write a if statement to check the TypeOf Control. The function is used like this
TypeName(Controls(i))
where i is the index of the control. You can use this to check the type of the current control in your loop and then perform the required property change.

Thanks,
Sunil

amram71
09-05-2000, 05:35 PM
Try This...

It's basically the same as sunil's, but in raw code.
(I'm too nice, aren't I)

Dim fCont as Control
For each fCont in Me
If TypeOf fCont=CommandButton hten
fCont.Cpation="ZZZ"
End If
Next fCont

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum