devxlogo

Maximum Number of Objects on a Form

Maximum Number of Objects on a Form

Question:
Is there any way to get more than 255 objects on a VB form?

Answer:
No, there’s not a way to pass the limit of 255 objects per form. If you’re hitting that limit, you should probably look at breaking your form into multiple forms.

In all the years I’ve been programming VB, I’ve never hit the control limit on forms I’ve built. There are many ways to share controls that are doing the same things. You can also get rid of controls like frames if you’re running short. By breaking controls on to multiple forms, you can save yourself some controls and give yourself more room to grow the form, if necessary.


On 3/30/00, readers Gene & Susan Thomaier commented:
There is a way around this limit (which, unfortunately, we hit): Use control arrays. We agree that one should try to break up the controls onto multiple forms, if possible and acceptable with a client.


On 3/30/00, reader John Laskowski commented:
Your answer is not totally correct. I had to recently work on a project where the design I walked in on had a tabbed control on a form that was driven by database tables for a world-wide repository of oil-well data. We ran into the 255 object limit pretty fast.

However, there is a way around the problem and you failed to mention it. Using the API calls of SetParent you can “swap” out frames on a form with another form that has a frame that has controls within. In this way you can switch parents hwnd’s and the form will “appear” to have more controls. It is a workaround, but that is what the user needs to do if he has to, not redesign his project.

See also  11 Effective Keyword Research Tools and Techniques

devxblackblue

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