I'm using Toolman's Public function and it's working as far as the divide by
zero, however, I'm trying to get a percentage. When I pass the two
parameters to it, if the result is 100.% it shows up. If it's anything else,
it shows 0.0%. Here is the function and the code.
Public Function DivideBy(ByVal exp1, ByVal exp2)
If exp1 = 0 Then
DivideBy = 0
Else
DivideBy = exp1 / exp2
End If
End Function
=code.DivideBy
( Fields!Under120_1.Value, Fields!TotalRecs.Value )
Any help is appreciated.
--
Thanks!Sounds like a datatype issue, maybe there is a conversion to int in your
expression?
I tried the expression:
=Code.DivideBy(5, 100) * 100
and it doesn't return zero or 100.
I wrapped a CInt() around it and I get that behavior.:
=CInt(Code.DivideBy(5, 100))
The CInt forces either a 0 or 1, then it's converted to percent.
"Candy" <Candy@.discussions.microsoft.com> wrote in message
news:3BBFBF2E-EAEB-4103-BC70-E81C14AE537F@.microsoft.com...
> I'm using Toolman's Public function and it's working as far as the divide
> by
> zero, however, I'm trying to get a percentage. When I pass the two
> parameters to it, if the result is 100.% it shows up. If it's anything
> else,
> it shows 0.0%. Here is the function and the code.
> Public Function DivideBy(ByVal exp1, ByVal exp2)
> If exp1 = 0 Then
> DivideBy = 0
> Else
> DivideBy = exp1 / exp2
> End If
> End Function
> =code.DivideBy
> ( Fields!Under120_1.Value, Fields!TotalRecs.Value )
> Any help is appreciated.
> --
> Thanks!|||Try CDbl() instead of CInt()
Also, make sure the values being passed are not integer values
Showing posts with label toolma. Show all posts
Showing posts with label toolma. Show all posts
Subscribe to:
Posts (Atom)