Hello,

I am working on debugging a program at my job. My coworker who wrote the program passed away last year, so it fell to me to try and update some changes we needed. I am a novice at programming and VB6 but was able to make the changes. Unfortunately, one bug remains.

Basically, the program collects data from another program and displays it in a column. The operator selects data points for various gases, then drags the data from a "collected data column" into a "report column". The operator continues to do that for all samples. If that operator needs to delete one of the columns from the report column, the program moves all other data to the left to fill out the table left to right. But when the operator does that, the value in the very last row of the first column changes from whatever value it is to "ND" (which means not detected).

The code that creates and clears the columns looks like this:

Private Sub UpdateColumnDisplay()

   Code to collect data which includes a loop for all columns
   At end of loop:

   Next Value ' Value = row
   Next Column
   Call ClearColumns(0)
End Sub

My first question - why is he passing a zero in ClearColumns? What does that do?

Then when you get to the ClearColumns procedure, it looks like this:

Private Sub ClearColumns(ColumnToErase As Long)
Dim Column As Long
Dim Value As Long


If ColumntoErase > 0
    grdReport.Col = ColumnToErase
    For Value = 0 to 13 'these are the rows
        grdReport.Row = Value
        grdReport = ""
    Next Value
Else
    For Column = ReportColumnNumber(ReportPage) + 1 To NumberGridColumns
    grdReport.Col = Column
        For Value 0 to 13
            grdReport.Row = Value
            grdReport = ""
        Next Value
    Next Column
End If

grdReport.Row = 0

For Column = ReportColumnNumber(ReportPage) + 1 To NumberGridColumns
    grdReport.Col = Column
    grdReport.Text = "("& Str$(Column + ((ReportPage - 1) * 5))&")"
Next Column

End Sub

Any help finding this bug would be appreciated. Thank you!

First, allow me to express my sympathy at losing a co-worker. Regardless whether he was your friend or associate, it is always a blow to a department or organization.

On to technical stuff:

It appears that if he passes a number other than zero as the parameter, it clears only that column (see line 6 above). If he passes a zero it clears ALL columns (see line 12). Finally, it re-initializes all the column headings (see line 22).

My guess is that he calls the ClearColumns subroutine from elsewhere in the program to selectively clear one column at a time.

Good luck! Hope this helps!

Thank you! Yeah, he was a coworker but we are such a small company that we are family. He was a great guy. And very particular about people touching the programs he wrote! So I am being cautious. :)

Thank you for the advice. I will have access again to the program this week and will check it out.

This article has been dead for over six months. Start a new discussion instead.