VBA表格可以容纳的控件的最大数量是多少? [英] What is the maximum number of controls that a VBA form can hold?

查看:500
本文介绍了VBA表格可以容纳的控件的最大数量是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建一个需要非常复杂表单的Excel 2003应用程序,并且担心控件数量受到限制。它目前有154个控件(使用 Me.Controls.Count 计数 - 这应该是正确的,对吗?),但可能只有大约三分之一完成。工作流真的适合一种形式,但我想我可以分裂它。如果我真的必须。



我在Google搜索中看到证据表明VB6(通常包括VBA)在表单中有254个控件的硬性限制。然而,我创建了一个有1200多个控件的虚拟表单,这些控件仍然加载并显示工作正常。



尝试使用时,我确实收到了一些内存不足错误添加特定的控件组合,比如说800个按钮和150个标签,让我认为任何限制都可能受到每种控件类型的内存需求的影响。



任何人都有任何信息可以帮助确保我或者更重要的是,具有不同环境的其他用户不会遇到这种大型表单的任何内存问题?

解决方案大多数MSForms控件都是无窗口的(因为它们不是真正的窗口,而是直接由VBA Forms引擎作为图形对象绘制),它们通过比较轻量级。这意味着你可以将更多的数据转储到一个用户表单上,而不是在VB6表单上使用等效的非MSForms控件。



我不知道上限是多少,但它可以是绝对限制或可用资源所施加的限制,所以如果你可以添加1,200而不会遇到那些< excel在内存使用方面表现自己,你应该没问题。



也就是说,控件的数量对于用户来说似乎仍然是一个非常可怕的问题! / p>

I'm currently building an Excel 2003 app that requires a horribly complex form and am worried about limitations on the number of controls. It currently has 154 controls (counted using Me.Controls.Count - this should be accurate, right?) but is probably only about a third complete. The workflow really fits a single form, but I guess I can split it up if I really have to.

I see evidence in a Google search that VB6 (this usually includes VBA) has a hard limit of 254 controls in a form. However, I created a dummy form with well over 1200 controls which still loaded and appeared to work just fine.

I did get some 'out of memory' errors when trying to add specific combinations of controls though, say 800 buttons and 150 labels, leading me to think that any limit might be affected by the memory requirements of each type of control.

Does anyone have any information that might help ensure that I or, more importantly, other users with differing environments don't run into any memory issues with such a large form?

解决方案

Most MSForms controls are windowless (as in they are not true windows, rather they are drawn directly by the VBA Forms engine as graphical objects) which are "light-weight" by comparison. This means you can dump more onto a Userform than you could using equivalent non-MSForms controls on a VB6 form.

I don't know what the upper limit is, but it will either be an absolute limit or a limit imposed by available resources, so if you can add 1,200 without encountering either of those & excel is behaving itself in terms of memory use you should be ok.

That said, that number of controls still seems an awful lot to present to the user at once!

这篇关于VBA表格可以容纳的控件的最大数量是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆