找回密码
 立即注册

QQ登录

只需一步,快速开始

tanto

注册会员

1

主题

1

帖子

14

积分

注册会员

积分
14
最新发帖

[已处理] 字符串截取

tanto
注册会员   /  发表于:2017-9-5 13:44  /   查看:3519  /  回复:2
数据内 的字段数据为  “mm/cm“,
显示时如何分别截取为 mm   cm


2 个回复

倒序浏览
williamluo
高级会员   /  发表于:2017-9-5 13:58:32
沙发
在脚本中定义两个自定义函数:

Function SplitMm(mmcm As String) As String
        Dim i = mmcm.IndexOf("/")
        If i >= 0 Then
                Return mmcm.Substring(0, i)
        Else
                Return mmcm
        End If
End Function

Function SplitCm(mmcm As String) As String
        Dim i = mmcm.IndexOf("/")
        If i >= 0 Then
                Return mmcm.Substring(i + 1)
        Else
                Return ""
        End If
End Function

然后在调用字段值的地方,使用表达式,调用上述函数:

=Code.SplitMm(Fields!字段名.Value.Tostring())
=Code.SplitCm(Fields!字段名.Value.Tostring())


回复 使用道具 举报
williamluo
高级会员   /  发表于:2017-9-6 16:11:47
板凳
更简单的办法是使用表达式:
=(Split(Fields!字段名.Value, "/")).GetValue(0)

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部