Welcome back, VBA!

Are you too old or too young? Clicking the button runs a VBA script, as explained in an article in Digital Education.

Are you too old or too young? Clicking the button runs a VBA script, as explained in an article in Digital Education.

It's nice to hear that VBA -- Visual Basic for Applications -- is one of the programming languages of choice for teaching the Computing curriculum.

I thought I was being an old stick-in-the-mud preferring it to Python, but on the STEM course I was teaching on recently, several delegates said they used it. They even encouraged me to republish an article I wrote in 2007 on how to teach iteration using VBA in Excel. I'm bringing that up-to-date (the menus in Excel have all changed since then), and it will be one of the articles in the next issue of Digital Education (which I'm also working on).

What's nice about VBA is that it's fairly intuitive. For example, a line of code like:

MsgBox "That ain't no number! Please try again"

may not be the most sophisticated programming ever seen, but it is pretty obvious what it does.

Also, as you type, VBA offers suggestions for attributes and so on, as shown here:

Help is at hand.

Help is at hand.

One of the things that seemed to emerge from our discussions on the course is that if you have never been exposed to VBA then you might as well just go with the flow and teach Python. But if, perhaps in the dim and distant past, you have used or played around with VBA, why not refresh your knowledge if necessary and adopt that as one of your programming languages?

Although it's looking a bit long in the tooth, VBA is a powerful language. Back in the day I used it to create a rota system for an ICT support surgery, a technical support incident logging system, an In-Service Training booking system and a lot of silly stuff, like the Homework Excuse Management System!

I've been told that it's a good basis for learning C++ too.

Another advantage is that if you already have Microsoft Office installed, then you have VBA. (I think this may not be the case with online versions of Office though -- I've been unable to find out, even from people within Microsoft. I suppose somebody must know, but I haven't come across them yet.)

I also appreciate the fact that you can create a small snippet of code and then test it to see if it works. It's not like the bad old days of Basic where you might write the whole program, only to discover that there was an error at line 730.

A couple of not-so-great aspects of VBA is that it's fairly easy to get away with sloppy code, and that the programs you create with it won't run outside the application they belong to. That is say, for instance, that my technical support systems will only run in Excel, not as a stand-alone executable application.

Still, given that the point of learning programming in school is to learn programming, that second point doesn't matter too much usually. I say "usually" because I've found that applications created in a particular version of an Office program and VBA sometimes don't work in later versions, which is mildly infuriating.

Still, on the whole, VBA is accessible and the sort of program where you can achieve quite a lot quite quickly. It certainly still has my vote.

As I said earlier, the next issue of Digital Education will feature a long-ish article on teaching iteration through Excel, and will include a step-by-step guide to creating a small procedure in VBA. If that sounds interesting, sign up here: