Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
First I know C# not VB but a little
I want to report my database with Microsoft Sql Server Report Service (it's better to say: the visual studio 2010 default reporting tools) for a windows form application.
In a matrix table I have a column "result" that every time contain a float value between 0 and 20 OR code 75 or 85. I want to show result value if result is between 0 and 20. In other case if result is 75, I want to report show string1 and if result is 85 show string2. So I wrote my VB function in Report Properties window in code section. this is my code
Function result_state(ByVal result AS single) AS string
IF (result == 85.00) then
    return "string2"
ELSEIF (result == 75.00) then
    return "string1"
ELSE
    reutrn System.Convert.Tostring(result)
END IF
END Function

Then I changed the column value to:
=Code.result_state(Sum(Fields!result.Value))

Visual studio says that the columns Expression has error. In Expression window the "result_state" underlined red and in running application following error occure:
VB
Error   1   There is an error on line 1 of custom code: [BC30201] Expression expected.  D:\projects\faqih\faqih\classrpt.rdlc   faqih

But program still working successfully and shows the report but 75 and 85 insteed string1 and string2.
Is my VB script is wrong?
Has my script usage mistake?
Or this is not correct solution for this problem?
Posted

1 solution

If the code in the post is a direct copy from your source code and you use custom codes, then at least these could be causing problems:
IF (result == 85.00) then

should be
IF (result = 85.00) then

then
reutrn System.Convert.Tostring(result)
should be (simplified):
return result.ToString()


There are few good examples here: http://msdn.microsoft.com/en-us/library/ms157328.aspx#CustomCode[^]

Also this could be done by using simply expressions. For examples, look: http://msdn.microsoft.com/en-us/library/ms157328.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900