Prev: RS2000 - rsWrongItemType
Next: Argument Not Specified For parameter 'TruePart' of Public Function
From: Carl Henthorn on 2 May 2007 11:52 I realize this thread is almost 2 years old, but I hope someone can help out. I have inserted the code below into my RS 2005 report,and get an error on line 0. "There is an error on line 0 of custom code: [BC30203] Identifier expected" can anyone help? thanks in advance "Clayton Groom" wrote: > I finally got tired of writing cryptic IIF() expressions in order to handle > divide by zero conditions and wrote the following report function that can be > added to any report. it simplifies the appearance of the code, and lets you > specify an alternate value such as zero or nothing when divide by zero > occurs. I hope this is helpful... > > ' Handle divide by zero gracefully > ' simpler than trying to use IIF() > Public Function CalcRatio(ByVal Numerator As Object, ByVal Denominator As > object, ByVal DivZeroDefault As Object) As Object > If Denominator <> 0 Then > Return Numerator/Denominator > Else > Return DivZeroDefault > End If > End Function > > Steps: > > From the menu, choose “Report”, “Report Properties”. > Click on the “Code” tab and past the above code into the window. > Click on “OK” > > To use the function, you have to reference the “code” collection in an > expression: > > =code.CalcRatio( Fields!PYGrossProfit.Value, Fields!PYSales.Value, Nothing) > > > Or if you want a zero instead of a blank: > > =code.CalcRatio( Fields!PYGrossProfit.Value, Fields!PYSales.Value, 0) > > > Enjoy! > -- > Clayton Groom > Covenant Technology Parnters, LLC > >
|
Pages: 1 Prev: RS2000 - rsWrongItemType Next: Argument Not Specified For parameter 'TruePart' of Public Function |