Tip of the week #1: Ctrl-Spacebar

Intro to Tip of the week

I will admit the blog has been a bit dead for a while. I have been busy with the code below, and its taking up alot of time:

so instead of trying to make some big post that I can’t seem to find the energy to neither start nor finish, I want to try a series of smaller useful tips. And this will be the first one.

IntelliSense

I am sure if you have coded anything in VBA you have run into IntelliSense, although you might not have been aware that it was called so. Basically it helps by showing you the syntax of the function, and especially the arguments required, and/or methods available on a class. Examples are when you start typing say a msgbox in vba, as soon as you hit >SpaceBar< a small tooltip will appear as seen in screenshot below

Demonstration of Intellisense

Demonstration of Intellisense

This is really useful as this helps remind you of what the arguments are, which order they come in, what type (long/string/object) of parameters they expect, and whether they are required or optional (Optional indicated by [Square brackets]) as well as the return type.

When used on a class object, such as a form, you get to see all the methods and properties of object. In a forms module, typing Me followed by dot (.) will bring up intellisense, as shown below:

Demonstration of IntelliSense used on Form

Demonstration of IntelliSense used on Form

Note that as I have typed me.tb (and tb is what I prefix my textboxes with) I can see that the current form has 2 named textboxes. Hitting >Tab< will then insert the selected text. So easy, because I don’t have to remember all the controls on my form, and if you follow a naming convention, its easy to filter to the type of control you are looking for. If it was a button I would just type me.cmd to see all my commandbuttons as they are prefixed with cmd. Immense timesaver.

 

Ctrl-Spacebar

Now most of you probably already know most if not all of the above, so now its time for the actual tip. You can “activate” or trigger IntelliSense even before typing anything, or after typing just a few letters. This is done by hitting Ctrl-Spacebar, and can be done from both a form, a module, or directly in the Immediate Pane. IntelliSense is even context aware, and using it from a form, will show you private subs and functions, as well as the global ones. So IntelliSense will not show you functions or subs you cannot call from the current scope.

This is useful if you have a lot of custom functions (or at least more functions than you can remember). For example, I have started prefixing my global functions with gf_ so typing gf_ and hitting Ctrl-Spacebar I will get a list of all my globally available custom functions. Or if I can only remember the beginning of the function name, I type a few characters, hit my Ctrl-Spacebar and get a list of the functions and subs starting with those letters.

An example is shown below, where I have a lot of functions that starts with Generate (and was written before I started the convention of using gs_)

IntelliSense on custom functions

IntelliSense on custom functions

 

I hope you find the information on IntelliSense useful, as well as the “Tip of the Week #1”, and don’t forget to subscribe to be notified when the next tip of the week comes out (hopefully next week….fingers crossed)

Posted in Tip Of The Week Tagged with: , , , ,
2 comments on “Tip of the week #1: Ctrl-Spacebar
  1. Is there any IntelliSense in your initial code snippet? And can we use Ctrl-Spacebar to deactivate it?

    Glad to see you’re back at the blogging and Tips are a good way to provide value.

    • TheSmileyCoder says:

      I believe that my own internal IntelliSense has been shut down for a while due to lack of sleep. I have tried many many many things to de-activate it, but it doesn’t seem to respond well to input. Maybe there is a api incompatibility. 🙂

Ask a question, leave some feedback, post a reply!