1、简单统计,参考
'''
Dim t As Table = Tables("出差记录")
Dim rs As Integer = 0
Dim hs As Integer = 0
For Each r As Row In t.Rows
If r("出差地点") Like "*以外" Then
hs = hs + 1
End If
If r("出差人") > "" Then
rs = rs + r("出差人").split("、").length
End If
Next
msgbox("出差地点不在本市行数:" & hs)
msgbox("出差地点不在本市人数:" & rs)
2、参考 http://www.foxtable.com/webhelp/scr/2400.htm
'''
Dim dt As DataTable
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("出差人", Gettype(String), 16)
dtb.AddDef("次数", Gettype(Double))
dt = dtb.Build()
'开始逐行累加统计
Dim lst As New Dictionary(of String ,DataRow) '定义一个字典,用于检索每个员工在统计表中对应的行
For Each dr1 As DataRow In DataTables("出差记录").DataRows
If dr1.IsNull("出差人") = False Then '如果工号列不为空
Dim nms() As String = dr1("出差人").Split("、") '将工号列内容拆分成数组
For Each nm As String In nms '遍历参与加工此产品的每个工号
Dim dr2 As DataRow
Dim key As String = nm
If lst.ContainsKey(key) '如果集合中包括此关键词对应的行
dr2= lst(key) '将此行赋值给变量dr2
Else
dr2 = dt.AddNew() '否则增加一行.
dr2("出差人") = nm '新增行的工号列设置为此工号
lst.add(key,dr2) '将新增行添加到字典中,以便接下来检索
End If
dr2("次数") += 1
Next
End If
Next
MainTable = Tables("统计")