SSRS Split expression #Error

你说的曾经没有我的故事 提交于 2019-12-24 18:28:19

问题


Trying to get this expression working:

IIF(Fields!Text.Value like "*som:*",Split(Fields!Text.Value, ": ").GetValue(0)&":" & vbcrlf & Split(Fields!Text.Value, ": ").GetValue(1), Fields!Text.Value)

And for the fields which contain "som:" it works as I want but not for the "else fields" which show #Error. I've also tried Fields!Text.Value.ToString().Contain("som:") but got the same result.

The Warning goes: The Value expression for the textrun ‘XXXXXX.Paragraphs[0].TextRuns[0]’ contains an error: Index out of matrix/range (trying translate it so sorry if the error message is not exact)

The expression is made on a textbox and I need to have this function cause our costumer requires it.

I want this input kinda:

TExt text text som:

text text text

and else

TExt text text text text text

What am I doing wrong?


回答1:


Please use custom code:

Report ► Report properties ► Code (Report is on the toolbar on the TOP)

Add below code:

Function Valid(ByVal str As String) As String
    If (str.Contains("tom:")) Then
        Return str.Split(":").GetValue(0) + ":" + vbCrLf + str.Split(":").GetValue(1)
    Else
        Return str
    End If
End Function

user like this: "=Code.Valid(Fields!Text.Value)"



来源:https://stackoverflow.com/questions/51185199/ssrs-split-expression-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!