使用SubString时iif出错 [英] Error in iif when SubString is used
问题描述
= iif(参数!Amount.Value.ToString()。Length() > = 3,
以下代码应该从给定数字的右侧打印第3个数字,如果数字小于3个数字,那么它应该什么都不打印。< br>
参数!Amount.Value.ToString()。Substring(Parameters!Amount.Value.ToString()。Length() - 3,1),
但是它print #Error和Error是" StartIndex不能小于零。" ;当Number小于3位时,如果Number大于3位,那么它运行良好。
我尝试了新的Code也如下,
= iif(参数!Amount.Value.ToString()。Length()> = 3, true , false )
它完美无缺。
所以我认为有一些bug(来自MS Side)或者一些混乱(从我这边)
亲切帮助。
我已经上传了示例项目 < font style ="font-size:12px"> www.gnwebsoft.com/Report.rar (219KB大小)
您好,
IIF我想,这不是最好的方式。你必须编写UserCode,因为IIF检查两种情况。真正的 AND 假案例。
这里是litle代码:
public function getSubstring(value as string )as string
if value.tostring.length> = 3然后
返回Value.ToString.Substring(Value.ToString.Length-3,1)
返回" ---"
如果
结束函数
和你称之为:
= code.getSubstring(参数!Amount.Value )搜索结果,HTH,搜索结果,英戈
Hi, =iif(Parameters!Amount.Value.ToString().Length()>=3,
Following Code should print 3rd Digit From Right Side of Given Number and If Number is smaller than 3 Digits then it should print nothing.
Parameters!Amount.Value.ToString().Substring(Parameters!Amount.Value.ToString().Length()-3,1),
But it prints #Error and Error is "StartIndex cannot be less than zero." when Number is smaller than 3 Digits, If Number is Larger than 3 Digits then it works well.
I tried new Code also as below,
=iif(Parameters!Amount.Value.ToString().Length()>=3,true,false)
and it worked perfectly.
So I think there is some bug (From MS Side) or some Confusion (From My Side)
Kindly Help.
I have uploaded sample project at www.gnwebsoft.com/Report.rar (219KB Size)
Hello,
the IIF is not the best way, i Think. You have to write UserCode, because the IIF check both cases. The true AND the false Case.
And here is the litle Code:
public function getSubstring(value as string) as string
if value.tostring.length > = 3 then
return Value.ToString.Substring(Value.ToString.Length-3,1)
else
return "---"
end if
end function
and teh way you call it:=code.getSubstring(Parameters!Amount.Value)
HTH,
Ingo
这篇关于使用SubString时iif出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!