报表的空白处点右键,报表属性,CODE,按下面的格式输入自定义函数:
Shared Function ShowDate(value as DateTime) as string
if value<=DateValue("1900-1-1") then
return ""
else
return FormatDateTime(value,DateFormat.ShortDate)
end if
End Function
![](https://images2015.cnblogs.com/blog/462334/201512/462334-20151224104936031-1232408019.png)
调用: 表达式中输入
=code.ShowNumber(Fields!PurchCC.Value,3)
![](https://images2015.cnblogs.com/blog/462334/201512/462334-20151224104936484-1739006793.png)
格式化数字:
Shared Function ShowNumber(value as Double, digit as integer ) as string
if value=0 then
return ""
else
return FormatNumber(value, digit)
end if
End Function