Originally posted by "Publius"...

 I'm working on VB6 code written by a Dutch speaker and maintained by an Italian, with variables and comments in both languages. And no indentation whatsoever.

Rather than use a string array, the original developers repeatedly feed the same, massive string literal into the Split function. This is done for every string resource the program uses.

For reasons beyond my understanding, there is this:

ikownjou = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...[snip]" & Chr(1)
ikownjou = ikownjou & "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...[snip]" & Chr(1)

Also, there are 40 timers on the main form, all arranged in a grid. It looks like Flava Flav's coat of arms.

Rather than use different resource files for the eight languages it's translated to, all four billion or so captions and menu items are set with a separate call to the locale("resource_name") function whenever a form is loaded. And whenever the locale() function is called, it opens a file, looks for the entry for the current language, and then closes the file.

Rather than use "Sub", they always use a "Function" with no return value that's peppered with about 70 "Exit Function" statements throughout its body.

Rather than use a database, all non-static information is crammed in thousands of text files scattered across subfolders of subfolders. Their version of "SELECT * FROM" is "DIR *.txt".

I replaced 4002 lines of this:

Public Function B64Length(ByVal TheString As String) As Integer
    Select Case TheString
        Case "@@"
            B64Length = 0
            Exit Function
        Case "@A"
            B64Length = 1
            Exit Function
        Case "@B"
            B64Length = 2
            Exit Function
        Case "@C"
            B64Length = 3
            Exit Function
        Case "@D"
            B64Length = 4
            Exit Function
----------[snip]------------
    End Select
End Function

With two lines:

Private Const B64Compare = _
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}- €" Public Function B64Length(ByVal strEncoded As String) As Integer B64Length = (InStr(1, B64Compare, Left(strEncoded, 1)) - 1) _
* 64 + (InStr(1, B64Compare, Right(strEncoded, 1)) - 1) End Function
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!