以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]单元格内容计数 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=126382) |
-- 作者:天一生水 -- 发布时间:2018/10/19 21:59:00 -- [求助]单元格内容计数 如图,怎样根据[代理案件]的内容,按照年度计数? [代理数量]代码如下,请教[年度代理数量]代码。 谢谢! Dim s As String = e.DataRow("代理案件") If s >"" Then s = s.replace(vbcrlf, vblf) Dim fls() As String = s.split(vblf) e.DataRow("代理数量") = (fls.Length) Else e.DataRow.delete End If |
-- 作者:有点蓝 -- 发布时间:2018/10/19 22:19:00 -- Dim dict As new Dictionary(of String,Integer) Dim s As String = e.DataRow("代理案件") If s >"" Then s = s.replace(vbcr, "") Dim fls() As String = s.split(vblf) For Each f As String In fls Dim s1 As String = f.SubString(1,4) If dict.ContainsKey(s1) Then dict(s1) = dict(s1) + 1 Else dict.Add(s1,1) End If Next Dim s2 As String = "" For Each key As String In dict.Keys s2 = s2 & key & "-" & dict(key) & vbcrlf Next msgbox(s2.Trim(vbcrlf)) Else e.DataRow.delete End If
|