top of page

Sometimes it's just the little things - #4: Tasks (aka TODOs)

John

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.


Any "grown up" code editor will allow you to add code comments that act as markers of work that is still to be done ... future tasks for yourself (or someone else if you work as a team). Typically these use the text "TODO" meaning, of course, that you (or someone) needs TO DO this.


As anyone that has used the VBE to write VBA code for more than 2 minutes will realise, it does not provide such functionality. There are two built in options that kind-of (in a very unsatisfactory kind-of way) provide similar functionality:


  • You can add code comments and then use the Find dialog to find them ... but it will only show you one 'found item' at a time ... not a list of them all and there is no way to sort or prioritise them

  • You can use Bookmarks (Edit > Bookmarks) ... but you have no way of listing them all, can only go to the next/previous, there is no information associated with the Bookmark (i.e. you cannot add any text describing why there is a Bookmark) and, worst of all, they are not saved with your VBA code


Never fear, though, because VBE_Extras does provide this functionality ... called "Tasks".


Tasks use code comments - and code comments in VBA always start with an apostrophe (don't get me started on Rem ... for Tasks, use an apostrophe), so a Task is always such as



Then, in the VBE_Extras main menu, select Extras > Tasks in this Project (or use Ctrl+Shift+T if you are using the default keyboard shortcuts) and you will get a dialog with all of the Tasks you have added to the active VBA Project e.g.


The Tasks dialog ... all Priority 2

As you can see, the list includes the Module name, Procedure (or Property) name (if not in the declaration lines of a Module), the line number within the Module, the Priority (more on that below) and the text of the Task itself.


You can filter the Tasks by typing in the text box at the top of the dialog. And, using the buttons at the lower right, you can generate a CSV list of all Tasks or you can go to a specific Task (i.e. VBE_Extras will activate the relevant Module and place the cursor at the appropriate line and column of the Task).


The text used to identify a Task in the above example is always TODO, however, you can use any text that you want (must contain only letters, digits, underscores or hyphens; must be from 2 to 12 characters in length). By default, VBE_Extras provides 6 texts for Tasks:


Settings for Tasks

... use the 'Task Items' tab of the Settings (Extras > Settings) to add your own and/or delete and amend the defaults. And this is where the Priority comes from (along with whether the comparison for the Task text is case sensitive and whether the specific Task text is active or not) ... so the list of Tasks shown is sorted first by Priority ... higher Priority (i.e. lower number) Tasks being shown first e.g.


The Tasks dialog ... differing Priorities

But my favourite part of this, when I'm working on a project and I click on Tasks in this Project is when I see this


No Tasks found!

... because it means I can clock-off for the day.


And that makes me smile!

Comments


bottom of page