When we work with reports, most of the times we need to do complex calculations and logic. When we do calculations, there are chances of using the division operation. So, need of checking the divided by zero problem every time. So the solution I propose is, write a simple custom function and call it wherever needed. For every report there is a part called Code and there we can write the custom VB code.
Public Function CheckDividedByZero(ByVal param1 As Double, ByVal param2 As Double) As Double
If param2 = 0 Then
Return 0
Else
Return param1 / param2
End If
End Function
So, call this function wherever you are performing the division operation. Hope this will solve your problem and you never face the divided by zero problem any more.
No comments:
Post a Comment