mrlemmer11
New Member
- Joined
- Jun 8, 2015
- Messages
- 32
Hello,
So I have 14 labels on a User Form. When the user form is loaded on stage 1 I want labels 1 thru 8 to be visible with text on them. when a command button is hit, i want labels 2 thru 9 to be visible with the text from the previous label to transfer to the next label, so the original text of label 1 would now be on label two, two would be on three, etc etc.
Sometimes though, the form can be loaded on a different stage... so the user may load it on stage 5 at which point I want labels 5 to 12 be visible and with different captions on them.
I believe I can write the code to have this be a function so I don't need to have 28 statements of .visible and .caption for each command button click, but I run into a situation where I can't seem to put my labels into an array....I need something where this a variation of the following works:
So I have 14 labels on a User Form. When the user form is loaded on stage 1 I want labels 1 thru 8 to be visible with text on them. when a command button is hit, i want labels 2 thru 9 to be visible with the text from the previous label to transfer to the next label, so the original text of label 1 would now be on label two, two would be on three, etc etc.
Sometimes though, the form can be loaded on a different stage... so the user may load it on stage 5 at which point I want labels 5 to 12 be visible and with different captions on them.
I believe I can write the code to have this be a function so I don't need to have 28 statements of .visible and .caption for each command button click, but I run into a situation where I can't seem to put my labels into an array....I need something where this a variation of the following works:
Code:
Sub labelSwitch(labelShown as control)
Dim x as integer
x = labelShown.Tag
for n = 1 to UBound(allLabels)
If allLabels(n).tag = x Then
allLabels(n).visible = False
allLabels(n+7).visible = True
for m = 1 to 7
allLabels(m + n).caption = allLabels(m + n -1).caption
next m
Else
End If
next n