setting label properties

  • Thread starter Thread starter Dave Peterson
  • Start date Start date
D

Dave Peterson

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 = ""
 
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
 
My apologies for using the wrong format.
Many thanks for the solution to the problem.
 

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

Back
Top