且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

VB 6:一个窗体上可以有多少个控件?

更新时间:2023-12-06 12:42:34

没有绝对限制.如果在窗体上放置足够多的控件,最终会耗尽内存.我制作了一个将命令按钮加载到控件数组中的测试应用程序.我的第一次运行在大约 6900 个按钮处因内存不足"错误而停止.我关闭了一些其他应用程序,能够加载近 8200.我对文本框做了同样的事情,得到了不同的结果(大约 7300 之前和 8600 之后).不同的控件消耗不同的内存量,因此实际上无法指定可以放在表单上的确切控件数量.

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.