简体   繁体   English

VB 6:我可以在一个表单上有多少个控件?

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

I know the limit for named controls is 254, beyond that you have to use control arrays. 我知道命名控件的限制是254,除此之外你必须使用控件数组。 But it seems we have hit the limit for arrays too. 但似乎我们也达到了阵列的极限。 Any idea what that absolute limit is? 知道绝对限制是什么吗?

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. 我的第一次运行因大约6900个按钮的“Out of memory”错误而停止。 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). 我关闭了一些其他的应用程序,并且能够加载近8200.我用文本框做了同样的事情并得到了不同的结果(之前大约7300和之后的8600)。 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. 不同的控件占用不同的内存量,因此实际上无法指定可以放在表单上的确切数量的控件。

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 (ie can't open up other windows). 我们有一个用VB6编写的记录管理系统,并且有一个UI指南,说明每个记录应该只有一个与之关联的数据输入表单(即无法打开其他窗口)。 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. 作为此策略的结果,我们系统中的一个更复杂的记录类型现在具有总共659个单独控件的表单。 We had run into the 256 named controls limit, and then converted many of the controls to control arrays over time. 我们遇到了256个命名控件限制,然后将许多控件转换为控制数组随着时间的推移。 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. 最近,在完成整个表单并将剩余的少量独立控件转换为控件数组之后,我们为5或6个新控件挤压了空间。

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). 无论如何,你可以在一个表单上放置至少659个控件,但我从来没有能够找出真正的绝对限制(我不确定我想要)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM