Oddities from the past

I had to debug some old VBA in a complex spreadsheet today and discovered the cause of the problem. The variable that held a key piece of data was declared like this:

Dim someValue as String * 3

Never having spent much time with VBA I had never come across this before, but it was easy to figure out what was going on. When the code was written that variable was never expected to be longer than three characters. So the string was restricted to 3 characters. Today, probably 15 years after it was first written, it needed to accept 4 characters for the first time. Oddly it doesn't throw an error it just takes the first three characters and ignores anything else.

Comments are closed