2

I have a counter NumObjects that I declare in UserForm1 which holds the number of labels added to the Userform.

When the Command Button Add Horizontal Table is clicked, the program calls a sub within the class module to add a label to the Userform.

The first table added has the caption "TEACHER" written on it; after this I want the labels to read 1, 2, 3....

So I tried using the counter NumObjects in the class module sub in the following statement: Lbl.Caption = (NumObjects - 1) but it complains NumObjects has not been defined.

How do I get the class module to realize the NumObjects variable?

1 Answer 1

1

NumObjects must be a public variable in the userform and you must prefix it with the userform name when using it elsewhere:

Lbl.Caption = (UserformName.NumObjects - 1)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.