VBE_Extras adds a whole load of functionality (see What is VBE_Extras) to the standard VBE. But sometimes, rather than the major areas of functionality, it's just the little things that it does that make me smile. Here's an example.
Qualifying references? Eh? For example, it's valid in VBA code to use the name of members in other Standard Modules without including the name of the other Standard Module in front of it. Without the name of the other Standard Module in front of it, the name of the member (i.e. the reference of that member) is unqualified. With the name of the Standard Module, it is qualified.
Unqualified references use less code, but they are also less clear code. By just looking at the name of the member, you cannot tell where it is within your Project. Which may well mean that you cannot tell what it does. For example (I'm making this up for effect ... obviously!) if you have a procedure call DeleteAll which is being called from code in a Module but it is not qualified with the name of it's Module then you have little understanding of what is being deleted.
However, if the call of DeleteAll is qualified with the name of the Module then its purposes can become much clearer ... FilesOnThisDevice.DeleteAll and TempData.DeleteAll suggest quite different things.
So, while it is valid in VBA code to use the name of members in other Standard Modules without including the name of the other Standard Module in front of it, it isn't really great to do so. It can be a bit of a hassle, though, to locate the Module in which the member is located and then type its name. Wouldn't it be better if there was some way of doing it automatically?
No surprise, then, that the 'Qualify reference' command of VBE_Extras does exactly this.

The 'Qualify reference' command is intelligent enough to know when a member is in the same Module as the reference of it and, in that case, does not qualify the reference ... it doesn't need to be qualified.
It also works across Projects: if you are working in a host application that allows multiple VBA Projects to be open at once and you have a reference from one (parent) Project to another (child) Project then, when you 'Qualify reference' for a reference of a member in a child Project from the parent Project, it will include the Project name as well as the Module name.
And ... it works for Enum members. As you can see in the demo above. If you 'Qualify reference' on the name of an Enum member that does not have the name of the Enum itself preceding it, then it will add it.
I find 'Qualify reference' most useful when I've inherited code from another developer and they couldn't be bothered to include the Module and Enum names.
Code clarified with one command. Makes me smile.
Comentários