VisualBasic was… an interesting beast. The language wasn't great, and because object orientation was awkwardly bolted onto it, but it also was heavily integrated into Microsoft's ActiveX libraries (heavily object oriented), there were all sorts of interesting ways to break your program with it. Even better: it was designed to be easy so that "anyone" could use it.

Which leads to some of this code, from Dave. A number of years back, Dave was asked to try and convert an ancient VB6 application into something modern. Like all such conversions, the brief was: "make a new application that does exactly what the old application does, but nobody actually knows what the old application does because we never documented any requirements, just read the code".

Reading the code had some "fun" moments, like this one:

Public fun As Single
Public funprime As Single

As well as a few code smells:

Public p As Single
Public po As Single
Public Poo As Single

VisualBasic's killer feature, though, was its UI designer. Drag and drop widgets onto a canvas. Double click on them and it pops you right into an event handling method. Just write what happens when the button is clicked. Flip back to the UI designer, and you've got a handy dandy panel to control things like the color, the font, and most important- the name of the button that gets used in code. Because the UI designer can't intuit what name you want, so when you add a button or a checkbox, it just gets named something like Button11. It's up to you to rename it btnSave (per the convention in VB circles).

Of course, nothing made you do that. Which means you end up with code like:

Private Sub Check22_Click()
If Check22 = 1 Then
    Check20 = 0
    Check21 = 0
    Check2.Enabled = True
    Check9.Enabled = True
    Check10.Enabled = True
    Check11.Enabled = True
    Check12.Enabled = False
    Check12 = 0
    End If
End Sub

Dave writes: "Waiter, check please!"

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!