I never thought I'd see code that warranted a WTF?
But here it is... spotted in an Access VBA project while working today.
' 4... Convert to positive number
If x <> 0 Then
gGetRecoveryCashPayments = x - (x * 2)
End If
x was known to be negative as it was the sum of a bunch of negative numbers. But the report should have displayed a positive to make more sense to humans.
Needless to say, the code is now:
gGetRecoveryCashPayments = -x
Typical of this project - when I finish reviewing & updating a module there is typically about 25% of the code left, more functionality and less bugs.
ps. laughed for about 15 minutes on this one!
pps. even worse, I had to test the logic... and it works!