如何在 VBA IDE 中使用“本地”窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1241343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 10:40:21  来源:igfitidea点击:

How to use the "Locals" window in VBA IDE

ms-accessvbaide

提问by Smandoli

When I'm coding VBA in Access 2003, I keep the Immediate window visible and I use Debug.Print and Stop to solve my challenges. But I've never known how to get help from the "Locals" window. I understand what's in there for the most part. But it usually seems like I'd have to dig around for the item I want, and it could take a while to find it in all those folded structures.

当我在 Access 2003 中编码 VBA 时,我保持立即窗口可见并使用 Debug.Print 和 Stop 来解决我的挑战。但我从来不知道如何从“本地人”窗口获得帮助。我了解大部分内容。但通常似乎我必须四处寻找我想要的物品,并且可能需要一段时间才能在所有这些折叠结构中找到它。

(And "Locals" doesn't bring up anything from the built-in VBA help files. Maybe I'm missing a file ...)

(而且“本地人”不会从内置的 VBA 帮助文件中调出任何内容。也许我错过了一个文件......)

I bet I could start using Locals, if I knew what it's good for in a practical way. Do do you have an explanation or anecdote that would clue me in?

我打赌我可以开始使用 Locals,如果我知道它以实用的方式有什么好处。你有什么解释或轶事可以让我了解吗?

回答by Dick Kusleika

Locals provides a couple of benefits: You can F8 through the code and watch how a variable changes by looking at the locals window as opposed to issuing debug.print statements or hovering over the variables. You can see the contents of an array a heck of a lot quicker than issuing lbound and ubound and a bunch of other statements to check values. Not just arrays either, but any complex data structure such as a custom class module.

Locals 提供了几个好处:您可以通过代码 F8 并通过查看 locals 窗口来观察变量如何变化,而不是发出 debug.print 语句或将鼠标悬停在变量上。与发出 lbound 和 ubound 以及一堆其他语句来检查值相比,您可以看到数组的内容要快得多。不仅是数组,还有任何复杂的数据结构,例如自定义类模块。