我拼命尝试用表达式(Mid / InStr)分隔字符串的特定部分。
字符串:从“ Doe,John”转移到“”,从“客户”组转移到“服务”
我需要组值:服务
有人可以帮忙吗?有可能吗?
答案 0 :(得分:0)
我能够用一个功能来做到这一点。
=Code.GetTransferedGroup(Fields!YourColumnNameHere.Value)
Public Function GetTransferedGroup(columnValue As String) As String
'--------------------------------------------------------------------------------------------------------------------
' Purpose: Seperate part of a string
' Example: =Code.GetTransferedGroup("Transfered from 'Doe, John' to '', Transfered from Group 'Customer' to 'Service'")
' Reference: https://stackoverflow.com/questions/52658830/ssrs-seperate-part-of-a-string-and-return
'--------------------------------------------------------------------------------------------------------------------
Const transferedHeader As String = "Transfered from Group"
Const transferedTerm As String = " to "
Dim transferedPart As Integer
Dim transferedValues As String
Try
transferedPart = InStr(1, columnValue, transferedHeader, vbBinaryCompare)
transferedValues = Mid(columnValue, transferedPart + Len(transferedHeader) + 1, Len(columnValue) - (transferedPart + Len(transferedHeader)))
return Replace(Mid(transferedValues, InStr(1, transferedValues, transferedTerm) + Len(transferedTerm), Len(transferedValues) - InStr(1, transferedValues, transferedTerm)), "'", "")
Catch
return "Error"
End Try
End Function