Function call giving an error | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Function call giving an error

Hello all, This is the Function: Public Dim GrossValue As double = 0.00 Public Function GetGrossValue(ByVal dPymt as Double,ByVal dFlag as Boolean) As Double
If(dFlag = False) Then
GrossValue = GrossValue + dPymt
Return GrossValue
Else
Return 0.00
End If
End Function Public Function ResetValue()
GrossValue = 0.00
End Function
I am calling this function in a textbox =IIF(Fields!IsEarnCancelled.Value,
Nothing,
(Code.GetGrossValue(Fields!Gross.Value,Fields!IsEarnCancelled.Value))) I DO NOT KNOW where I am doing wrong. But it is giving me "The Value expression for the textbox ”textbox200" contains an error: Input string was not in correct format. Please help
Thanks,
Deepak
Hi,
I’m not familiar with RS but I know some VB and based on your error, i can make a wild guess. consider this:
IIF(Fields!IsEarnCancelled.Value,
Nothing,
(Code.GetGrossValue(Fields!Gross.Value,Fields!IsEarnCancelled.Value))) replace it with
IIF(Fields!IsEarnCancelled.Value,
Nothing,(Code.GetGrossValue(VAL(Fields!Gross.Value),FALSE))) Here I replaced Fields!IsEarnCancelled.Value with FALSE because this part will be called only when IIF finds the value other than TRUE.
If it runs correctly, then you can even remove passing boolean flag which I think not required then.

Thanks Ranjith for the response. I have replaced my code with the code that you sent accross, but it is still giving an error. The result’s are showing perfectly fine in both the cases but it is showing Warning Message like this "The Value expression for the textbox textbox200" contains an error: Input string was not in correct format." Thanks,
Deepak
]]>