I am trying to reformat a string, if it is numeric, to look like money ($999,999.99). Otherwise, return the string unchanged.
I have written the follwoing code in the report properties code tab:
Public Shared Function funFormatString(strToBeFormated as String) as string
dim intLen as integer
IF isnumeric(strToBeFormated)
intLen = len(strToBeFormated)
SELECT CASE intLen
CASE 1 to 6
strToBeFormated = "$" + strToBeFormated
CASE 7 to 9
strToBeFormated = "$" + left(strToBeFormated, intLen - 6) + "," + right(strToBeFormated, 6)
CASE 10 to 12
strToBeFormated = "$" + left(strToBeFormated, intLen - 9) + "," + mid(strToBeFormated, intLen - 6, 3) + right(strToBeFormated, 6)
END SELECT
END IF
return strToBeFormated
End Function
When I go into my text field on the report, I enter the following in the expression to call the function:
=funFormatString(Fields!Q4Amt.Value)
The error I am recieving is:
The value expression for the textbox xxx contains an error: [BC30451] Name 'funFormatString' is not declared.
What am I doing wrong?
Thanks,
msflinx
I have written the follwoing code in the report properties code tab:
Public Shared Function funFormatString(strToBeFormated as String) as string
dim intLen as integer
IF isnumeric(strToBeFormated)
intLen = len(strToBeFormated)
SELECT CASE intLen
CASE 1 to 6
strToBeFormated = "$" + strToBeFormated
CASE 7 to 9
strToBeFormated = "$" + left(strToBeFormated, intLen - 6) + "," + right(strToBeFormated, 6)
CASE 10 to 12
strToBeFormated = "$" + left(strToBeFormated, intLen - 9) + "," + mid(strToBeFormated, intLen - 6, 3) + right(strToBeFormated, 6)
END SELECT
END IF
return strToBeFormated
End Function
When I go into my text field on the report, I enter the following in the expression to call the function:
=funFormatString(Fields!Q4Amt.Value)
The error I am recieving is:
The value expression for the textbox xxx contains an error: [BC30451] Name 'funFormatString' is not declared.
What am I doing wrong?
Thanks,
msflinx