set Text for all controls in a form

  • Thread starter Thread starter touf
  • Start date Start date
T

touf

Hi,
I need to change the labels of all controls in a form, for this I wrote a
code that loop form.controls and set the text property (to control.name for
example).
The problem is that some controls don't have a TEXT property (tabpages for
example)

Is there a way to do this?
Thanks

here is my code:
==========
dim cnt as control
for each cnt in myForm.controls
cnt.text = cnt.name
next
 
touf said:
Hi,
I need to change the labels of all controls in a form, for this I wrote a
code that loop form.controls and set the text property (to control.name
for example).
The problem is that some controls don't have a TEXT property (tabpages for
example)

Is there a way to do this?
Thanks

here is my code:
==========
dim cnt as control
for each cnt in myForm.controls
cnt.text = cnt.name
next
Dim cControl As Control For Each cControl InMe.Controls If (TypeOf
cControl Is TextBox) Then cControl.Text = "abc" End If Next
cControl-------------You'll need a Case Statement or if(s) if you like
checking the TypeOfcontrol, and you knowing upfront whether or not the
control has Text property.
 
Dim cControl As Control
For Each cControl InMe.Controls
If (TypeOf cControl Is TextBox) Then
cControl.Text = "abc"
End If

Next cControl

You'll need a Case Statement or if(s) if you like checking the TypeOf
control, and you knowing upfront whether or not the control has Text
property.
 
touf said:
Hi,
I need to change the labels of all controls in a form, for this I wrote a
code that loop form.controls and set the text property (to control.name
for example).
The problem is that some controls don't have a TEXT property (tabpages for
example)

Is there a way to do this?
Thanks

here is my code:
==========
dim cnt as control
for each cnt in myForm.controls
cnt.text = cnt.name
next

If you don't have to do this often you can just wrap your cnt.text =
cnt.name in a try catch and if the control does not have a text property it
will do whatever you want in the exception handler.

LS
 
Back
Top