这样就行了:
Tables("表A").Sort = "第一列,时间"
Tables("表A").Filter = "第一列 is not null"
Dim d As Date
Dim r As Row
Dim r2 As Row = Tables("表A").Rows(0)
Dim t As new timespan(0,0,0,0)
For i As Integer = 0 To Tables("表A").Rows.Count - 1
r = Tables("表A").Rows(i)
If r2("第一列") = r("第一列") Then
If r2("出入") = r("出入") Then
r2 = r
Continue For
ElseIf r.IsNull("时间") = False AndAlso r2.IsNull("时间") = False
r("第四列") = (cdate(r("时间")) - cdate(r2("时间"))).TotalSeconds
End If
Else
r2 = r
End If
Next
DataTables("表B").DataRows.clear()
For Each nm As String In DataTables("表A").GetValues("第一列")
Dim dr As DataRow = DataTables("表B").aDdnew()
dr("第一列") = nm
dr("工作时间汇总") = DataTables("表A").Compute("sum(第四列)","第一列= '" & nm & "'")
Next
记得将第二个表的工作时间汇总列改为时段型。