Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB 6: How many controls can I have on a single form?

Tags:

vb6

I know the limit for named controls is 254, beyond that you have to use control arrays. But it seems we have hit the limit for arrays too. Any idea what that absolute limit is?

like image 520
Jonathan Allen Avatar asked Jun 28 '10 17:06

Jonathan Allen


People also ask

How many default controls are available in VB?

The three basic VB controls are the Label, Textbox, and Button; these are the controls we will be working with for this program.

What is control array in vb6?

In Visual Basic, a control array is a group of related controls in a Visual Basic form that share the same event handlers. Control arrays are always single-dimensional arrays, and controls can be added or deleted from control arrays at runtime.

What are forms and controls in a VB project?

Visual Basic Form is the container for all the controls that make up the user interface. Every window you see in a running visual basic application is a form, thus the terms form and window describe the same entity. Visual Studio creates a default form for you when you create a Windows Forms Application.

Which control can be used to write something on a VB form?

A TextBox control is used to display, accept the text from the user as an input, or a single line of text on a VB.NET Windows form at runtime. Furthermore, we can add multiple text and scroll bars in textbox control. However, we can set the text on the textbox that displays on the form.


2 Answers

There is no absolute limit. If you put enough controls on the form, you'll eventually run out of memory. I made a test app that loads command buttons into a control array. My first run stopped with an "Out of memory" error at around 6900 buttons. I shut down a few other apps and was able to load nearly 8200. I did the same thing with text boxes and got different results (about 7300 before and 8600 after). Different controls consume different amounts of memory, so there really is no way to specify an exact number of controls that you can put on a form.

like image 126
raven Avatar answered Oct 26 '22 19:10

raven


We have a records management system written in VB6 and there is a UI guideline that says each record should have exactly one data entry form associated with it (i.e. can't open up other windows). As a result of this policy, one of the more complex record types in our system now has a form with a total of 659 individual controls. We had run into the 256 named controls limit, and then converted many of the controls to control arrays over time. Recently, we squeezed room for 5 or 6 new controls, after going through the entire form and converting the few remaining standalone controls to control arrays.

This is one time where I would like to break the rules, but that would involve quite a bit of refactoring to use a multiple form approach.

In any event, you can fit at least 659 controls on a form, but I've never been able to find out what the true absolute limit is (and I'm not sure that I want to).

like image 37
Mike Spross Avatar answered Oct 26 '22 19:10

Mike Spross