Friday, 22 March 2013

Memories of Visual Basic 6

In the UK it is typical to study for two years and then have a placement year where you actually get a job before the final fourth year of study.  In 2006 I took on several small projects over the placement  year and pushed VB6 to it's limits.  VB6 has so many quirks, it is impossible not to use hacks to get things done.  Here are some of mine.

One tool required a DSL for interacting with phones, it would read a list of phone numbers and a file containing commands and run them over each of the numbers.  For example it would make a call to the phone and configure it using DTMF* tones.  I had no idea at that time how a compiler could be properly implemented so the resulting code was a complete mess and the DSL was looked like assembly for telephones.  Despite the hideous code, the program saved a lot of time.  To do this manually would have taken days instead of a couple of hours and be impossibly error prone.  One key missing feature was error handling, which is problematic in telecommunications.  Inevitably one of the calls would go wrong and the program would crash, the operator would then have to delete the completed phones numbers from the list and run the program again.  No problems!

Another project provided a UI for editing INI file configuration.  The program was great, except that VB does not allow more than 256 controls on a single form.  My 'ingenious' solution was to put each INI section in a tab pane which also had its own window.  When the user clicked a new tab, it hid the current window and showed a new window for that tab. 

VB6 also comes with it's own TCP control which you must drag onto the UI to instantiate.  The problem is that it had almost the same API as a serial connection control, meaning it only dealt with 1 to 1 connections.  This meant it was impossible to write a TCP server.  That is, until I worked out that an array of TCP controls waiting for connections worked pretty much like a TCP server.  This is OK except that an array has a finite capacity, I was again limited by the number of controls so the server could only ever handle a certain number of connections.

I remember the year, the work and the company fondly and hope that some of my work is still in use.  Looking back, I don't know why I used VB6 for everything.  It's just so easy to get started and then keep typing, I was young and naive, that's all I can say...

* DTMF tones are those strange sounds you hear when you press a number on a phone key pad.  Pieces of hardware such as phones and switches can interpret a sequence of tones as commands.

No comments: