RAYLWARD102
Well-known Member
- Joined
- May 27, 2010
- Messages
- 529
Already know how to do this by using the user form name
Example of a user form named u1:
I know how to create controls the above way, on demand dynamically (by directly referencing the user form name)
I'm trying to add controls dynamically, without explicitly referencing the user form name.
An error occurs when I go to set the .height of the label.
Example:
Basically, I have some code that I want to use in various named userforms and was trying to build a function that would build out controls to a defined userform
rather than duplicating code for each of my various named user forms.
Basically, I do not want to address the user form by it's name when creating controls; I want address the userform by variable name
Example of a user form named u1:
Code:
Set LAB = u1.Controls.Add("Forms.Label.1")
I know how to create controls the above way, on demand dynamically (by directly referencing the user form name)
I'm trying to add controls dynamically, without explicitly referencing the user form name.
An error occurs when I go to set the .height of the label.
Example:
Code:
For x = 0 To UserForms.Count - 1
If LCase(UserForms.Item(x).Name) = LCase("u1") Then
UserForms.Item(x).Controls.Add ("Forms.Label.1")
With LAB
.Height = 10
End With
End If
Next
Basically, I have some code that I want to use in various named userforms and was trying to build a function that would build out controls to a defined userform
rather than duplicating code for each of my various named user forms.
Basically, I do not want to address the user form by it's name when creating controls; I want address the userform by variable name
Last edited: