View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default setting label properties

Thanks for changing format <bg.

And you're welcome.

81147leo wrote:

My apologies for using the wrong format.
Many thanks for the solution to the problem.

Dave Peterson wrote:
First, this is a plain text newsgroup--attachments and HTML/RTF posts aren't
welcomed by most.

Dim i as long
for i = 1 to 20
frmcreated.controls("lstate" & i).caption = ""
next i

If this is in code that is in the userform module, I'd use:
me.controls("lstate" & i).caption = ""



81147leo wrote:

Good Morning,

I have a user form with 20 labels on it - named 'lstate1' through 'lstate20'.
I would like to be able to set/clear the captions property within a loop by
using a variable to modify the label name. Something like this -

Sub frmclr()
dim i as integer
i =1
For i = i to 20
frmcreated.lstate1.caption = ""
next i
End sub

. . .but using the variable 'i' in place of the numeric in the label name to
select the proper label. I'm using a 'For each ctrl in Controls' routine that
works but I'd like to do it with the method suggested above.

thanks,
Leo




--

Dave Peterson