问题
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.
(And "Locals" doesn't bring up anything from the built-in VBA help files. Maybe I'm missing a file ...)
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?
回答1:
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.
来源:https://stackoverflow.com/questions/1241343/how-to-use-the-locals-window-in-vba-ide