我正在将Crystal报告转换为MS报告。 我在Crystal报告中的表达是这样的:
=IIF(Fields!foo.Value Is Nothing and Fields!bar.Value Is Nothing,
0,
IIF(Fields!foo.Value Is Not Nothing and Fields!bar.Value Is Nothing,
Fields!foo.Value,
IIF(Fields!foo.Value Is Nothing and Fields!bar.Value Is Not Nothing,
Fields!bar.Value * -1,
IIF(Fields!foo.Value Is Not Nothing and Fields!bar.Value Is Not Nothing,
Fields!foo.Value,
0
))))
Not
在这里不起作用,即使文字是蓝色的。
我可以使用Not
或!
之类的内容吗?或者我必须对IsNothing()
答案 0 :(得分:2)
哦,我想通了,我只需要将Not
移到表达式的开头。
这是我的VB.NET语法错误。来自C#,VB.NET和MS Reports对我来说都是新手,对不起。
=IIF(Fields!foo.Value Is Nothing and Fields!bar.Value Is Nothing,
0,
IIF(Not Fields!foo.Value Is Nothing and Fields!bar.Value Is Nothing,
Fields!foo.Value,
IIF(Fields!foo.Value Is Nothing and Not Fields!bar.Value Is Nothing,
Fields!bar.Value * -1,
IIF(Not Fields!foo.Value Is Nothing and Not Fields!bar.Value Is Nothing,
Fields!foo.Value,
0
))))
答案 1 :(得分:2)
您应该能够将表达简化为:
IIF(Not Fields!foo.Value Is Nothing,
Fields!foo.Value,
IIF(Not Fields!bar.Value Is Nothing,
Fields!bar.Value * -1,
0))
编辑:要返回foo.Value - bar.Value,当两者都不为null时,请尝试:
= IIF(Not Fields!foo.Value Is Nothing, Fields!foo.Value, 0) -
IIF(Not Fields!bar.Value Is Nothing, Fields!bar.Value, 0)
答案 2 :(得分:0)
试试这个:
=IIF((Fields!foo.Value.Equals(System.DBNull.Value)), "YES", "NO")
=IIF((Fields!foo.Value is System.DBNull.Value), "YES", "NO")