Constituent Controls are Private to UserControl Modules

Constituent Controls are Private to UserControl Modules

You cannot directly access constituent controls on a UserControl component from another module of the sameproject. Constituent controls behave differently from controls on forms, which you can access from any othermodule using the familiar “Form1.Text1” syntax. If you need to work around this limitation, have eachUserControl component expose its controls using a Friend property.For instance, if the UserControl1 module needs to expose one of its constituent controls, add this propertyprocedure:

 Friend Property Get TextControl() _        As TextBox                Set TextControl = Text1End Property

When you wish to modify the Text property of the control of a particular instance of UserControl1 in the BASmodule, write something like this:

 Sub ClearText(uc As UserControl1)        uc.TextControl.Text = ""End Sub
See also  How AI Art Generators Can Save Time and Money for Startups

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist