Splefty
splef-ty \'splef-te̅ \ adj: nifty, novel, cool or clever.
computers/visualbasic
Wed, 29 Oct 2003

Why I hate Visual Basic, part 112.

So one of the core controls in Microsoft Windows is the ListView control. This control is what you see when listing a directory under Windows 2000. This control has tons of bugs in it; for example, you are supposed to be able to set the important Key property of a ListItem to any unique string, but the ListView control will actually choke at run time if the string you pass it just happens to be all numbers, like “12522”. This is because of a pervasive (and annoying) belief among Visual Basic’s developers that it is just too hard for programmers to keep track of data types, and they should just use the Variant data type for everything. Somewhere deep in the control, some routine has decided that if I pass a string of numbers, it’s probably because I’m some bozo who doesn’t know how to pass numbers as numbers. So it converts the string to a numerical value before passing the result to the SetKey method, which promptly generates a runtime error because the Key property needs to be a string. Which it was, before the software changed it behind my back.

But that’s not actually what I’m annoyed about right now. Rather, it’s the fact that there is more than one ListView control (“ComctlLib.ListView” and “MSComctlLib.ListView”). They are incompatible with each other and there’s no explicit way to tell which one you are using. Since they are both called just “ListView” I didn’t even notice I’d used the wrong one until I’d wasted about 45 minutes trying to track down runtime errors.

And look, I know they need to add new features without breaking old ones so it is inevitable that Windows is littered with stuff like this. But would it really have killed them to add the class name to the property window?

ComCtl.ListView

comctl

MSComCtl.ListView

mscomctl

So I’m writing this entry so that I can remember “the one with all of the extra properties is MSComCtl.ListView”. If I programmed in VB every day, I’d already know this. Fortunately my life is not that grim.

Microsoft wants me to switch to the .NET frameworks, which they say will make everything better. They may be right. On the other hand, that’s what they always say.

[/computers/visualbasic]