• Labels On Userforms (2000)

    Author
    Topic
    #448303

    I have a userform on which are placed several labels. The labels are named:
    lbl1, lbl2, lbl3 etc. I want to generate a random number and use that number to select the label and change its background colour.
    Eg, random number 6 then lbl6 is referenced.
    I’ve done this before, I’m sure, but the syntax for referencing the label with a variable eludes me.
    Any takers?

    TIA

    Viewing 0 reply threads
    Author
    Replies
    • #1095908

      Let’s say that you have a variable intLabelNo. You can use code similar to this:

      intLabelNo = Int(10 * Rnd + 1)
      Me.Controls(“lbl” & intLabelNo).BackColor = vbRed

    Viewing 0 reply threads
    Reply To: Labels On Userforms (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: