Desperate times call for desperate measures, and in the midst of the Great Recession there’s quite a lot of desperation going on. Hourly bill rates that once made lawyers blush have come crashing down to the point of “wow, my gardener charged more than that.” And while the whole idea of “being selective with projects” is still around, the bar for what’s accepted has dropped to any and all projects. It ain’t pretty out there, especially for folks on the front lines like Matt.

“Four years ago,” Matt writes, “my company swore that we’d never talk to Initrode Global again. It wasn’t just their massive VB6 application that they refused to even consider upgrading, it was more that they insisted on fixed-bid estimates and constantly low-balled our numbers. Oh, and halfway through a project, they’d insist that we throw in an out-of-scope feature for free, since they were a paying customer and all.”

Matt continues, “now guess who we just landed a new contract with. Yeah."

”I hadn’t touched VB6 in years and told myself, it really wasn’t that bad. And when I opened up the codebase once again, I realized something else: VB6 itself wasn’t that bad… but Initrode Global’s codebase sure was.

When he fired up the application, only to have it crash due to a stack overflow, he them remembered the "trick" about the logging subroutine. And all the fun with how it, and all the other code, was written.

'This Subroutine is used to add entries to the system log file
Public Sub LogEntry(strFunction As String, strMsg As String)
    
Dim strLogFileName As String
Dim strPathAndFileName As String
    
'Set up error handling
    On Error GoTo ErrorHandler
    
'Check that System Logging is enabled
    If Form1.chkLogEnabled.Value = 1 Then
        
'Create the file name for the current day
        strLogFileName = "Logs\" & CStr(Year(Now)) & CStr(Month(Now)) & CStr(Day(Now)) & "_Log.txt"
        
'Create the full path name
        strPathAndFileName = SYSTEM_FOLDER & strLogFileName
        
'If the Log File exists then
        If FileExists(strPathAndFileName) Then
            
'Append to the end of the file - open for append
            Open strPathAndFileName For Append As #1
        Else
            
'Otherwise open a new file and add the new message - Open for output
            Open strPathAndFileName For Output As #1
        
'End if system log file exists
        End If
        
'Write the new line to the system log file
        Print #1, Format(Date, "mm/dd/yyyy") & "  " & Format(Time, "hh:mm:ss") & "  " & strFunction & "  " & strMsg
        
'Close the system log file
        Close #1
    
'End if system logging is enabled
    End If
    
'Exit subroutine
    GoTo EndSub

'Error Handling Section
ErrorHandler:

'Get Windows Error Description
    strError = Err.Description

'Write the System Log
    Call LogEntry("LogEntry: ", strError)

'Resume
    Resume Next
    
EndSub:
End Sub

Matt continued, “And yes, the comments always started on first column, no matter what level the code is indented to. Makes it really tough to keep track of where you are working.”

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!