堆栈控件不足(错误 28)

堆栈是随执行程序的要求动态增大和缩小的内存工作区。 此错误具有以下原因和解决方案:

  • You have too many active Function, Sub, or Property procedure calls. 检查过程未嵌套过深。 对递归过程(即,调用其本身的过程)尤其如此。 Make sure recursive procedures terminate properly. Use the Calls dialog box to view which procedures are active (on the stack).

  • 局部变量要求的局部变量空间超过可用空间。

    Try declaring some variables at the module level instead. You can also declare all variables in the procedure static by preceding the Property, Sub, or Function keyword with Static. Or you can use the Static statement to declare individual Static variables within procedures.

  • You have too many fixed-length strings. Fixed-length strings in a procedure are more quickly accessed, but use more stack space than variable-length strings, because the string data itself is placed on the stack. Try redefining some of your fixed-length strings as variable-length strings. When you declare variable-length strings in a procedure, only the string descriptor (not the data itself) is placed on the stack. You can also define the string at module level where it requires no stack space. Variables declared at module level are Public by default, so the string is visible to all procedures in the module.

  • You have too many nested DoEvents function calls. Use the Calls dialog box to view which procedures are active on the stack.

  • Your code triggered an event cascade. An event cascade is caused by triggering an event that calls an event procedure that's already on the stack. An event cascade is similar to an unterminated recursive procedure call, but it's less obvious, since the call is made by Visual Basic rather than by an explicit call in your code. Use the Calls dialog box to view which procedures are active (on the stack).

若要显示“调用”对话框,请在“调试”窗口中选择“过程”框右侧的“调用”按钮,或选择“调用”命令。 有关其他信息,选择有问题的项并按 F1(在 Windows 中)或 HELP(在 Macintosh 上)。

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。