Question : Function to check results

Hi there, I have a function that returns an integer.

=IIF(Sum(Fields!SubmitUnits.Value)<>0,Round((Sum(Fields!ApprovedUnits.Value-Fields!CancelledUnits.Value)/Sum(Fields!SubmitUnits.Value))*100,2),0)

I want to write a vb custom code function that checks the results, if they are under 0 then return 0, if they are above 100 then return 100. Can anyone show me how to do that?

Answer : Function to check results

dim retVal as integer
function GetResult(ByVal subUnits as Decimal, ByVal AppUnits as Decimal, BYVal canUnits as Decimal) as Integer
dim res as decimal
if subUnits <> 0 then
res = AppUnits-CanUnits/SubUnits
if res < 0 then
  return 0
else
 return 1
end if
else
return 0
end if
end function

finally in the expression, =Code.GetResults(param1, param2, param3)
Random Solutions  
 
programming4us programming4us