以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 合并计算问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=192467) |
-- 作者:yaojun -- 发布时间:2024/6/24 15:09:00 -- 合并计算问题 我想做到只计算/后面的数字,/前面的不参与计算,怎么改代码,原代码如下: Select Case e.DataCol.Name Case "累计生产数量" If e.NewValue Is Nothing Then \'如果新值是空白,也就是品名列的内容为空 e.DataRow("累计完成") = Nothing \'那么清空此行单价列的内容 Else Dim mc = System.Text.RegularExpressions.Regex.Matches(e.NewValue , "[0-9\\.]+") Dim sum As Double = 0 For i As Integer = 0 To mc.count-1 output.show(mc(i).value) sum += val(mc(i).value) Next e.DataRow("累计完成") = sum End If End Select 谢谢! |
-- 作者:有点蓝 -- 发布时间:2024/6/24 15:17:00 -- Else Dim sum As Double = 0 dim s1() as string = e.NewValue.replace(vbcr,"").split(vblf) for each s11 as string in s1 dim s2() as string = s11.split("/") sum = sum + val(s2(1)) next e.DataRow("累计完成") = sum End If End Select
|