set Text for all controls in a form

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
 
M

Mr. Arnold

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.
 
M

Mr. Arnold

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.
 
L

Lloyd Sheen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top