tags:

views:

239

answers:

4

Working in a classic VB6 app, crazy comments by the thousands.

Example:

If garrFilePaths(i).FilePath = "" Then
'do nothing
Else
MsgBox "File Not Found (" & garrFilePaths(i).FilePath & ")", vbOKOnly, gcstrMessageBoxTitle
End If

+2  A: 

Refactor so it makes sense. Not a lot to "handle", just remove the cruft so you don't have to spend brain-cycles on it.

Perhaps talk to the developer who wrote it, and/or work on guiding documents (coding standards) to help people do the right thing.

unwind
+4  A: 

Restructure the code and delete them.

If Not (garrFilePaths(i).FilePath = "") Then
    MsgBox "File Not Found (" & garrFilePaths(i).FilePath & ")", vbOKOnly, gcstrMessageBoxTitle
End If

This often works for comments that do make sense too.

Bill the Lizard
It was a while since I did Basic, but I think that could be garrFilePaths(i).FilePath <> "".
legoscia
@legoscia: It's been awhile for me too, but I think those will be equivalent statements.
Bill the Lizard
@legoscia: Yes, I just confirmed, that would be equivalent syntax. http://msdn.microsoft.com/en-us/library/2hxce09y.aspx It took me an embarrassingly long time to figure out how to search for `<>`. :)
Bill the Lizard
+1, code like the one in the example should be refactored where possible... it makes it easier to read and less prone to mistakes
laura
This is not equivalent condition, especially if `On Error Resume Next` is used.
wqw
@wqw: How is this not equivalent to the code in the question?
Bill the Lizard
+1  A: 

/* * No Comment */

dwolvin
'No Comment, surely?
wefwfwefwe
+2  A: 
If garrFilePaths(i).FilePath = "" Then
'do nothing 'fool
Else
MsgBox "File Not Found (" & garrFilePaths(i).FilePath & ")", vbOKOnly, gcstrMessageBoxTitle
End If
acidzombie24
EPIC!!!! right on! classic