自己设法解决,方法是先将时间转换为以秒为单位的数值格式,乘以5以后再转换成时间格式。有没有更简洁的方法,请各位老师指教,谢谢
For Each dr As DataRow In DataTables("C").DataRows
Dim N As Integer
Dim mr As DataRow = dr
Dim drs As List(of DataRow)
If dr.IsNull("用时") Then
dr = DataTables("C").Find("[序号] < " & mr("序号") & " And [员工] = '" & mr("员工") & "'And [日期] = '" & mr("日期") & "'", "[序号] Desc") '找出上一行
If dr Is Nothing Then '如果没有找到上一行,说明本行就是第一行
N = mr("工时")
mr("用时") = (new Date(1,1,1,0,0,0)).AddSeconds(N)
dr = mr
End If
drs = DataTables("C").Select("[序号] >= " & dr("序号") & " And [员工] = '" & dr("员工") & "'And [日期] = '" & mr("日期") & "'", "[序号]")
For k As Integer = 1 To drs.Count - 1 '重算余下行的时差
Dim t As TimeSpan = CDate(drs(k)("时间")) - CDate(drs(k-1)("时间"))
Dim d4 As Integer = t.Hours * 3600 + t.Minutes * 60 + t.Seconds
Dim N1,h,m,s As Integer
Dim sj As Date
N1 = d4 * 5
h = N1 \ 3600
m = (N1 Mod 3600) \ 60
s = N1 Mod 60
drs(k)("用时") = Format(new Date(1,1,1,h,m,s), "HH:mm:ss")
Next
End If
Next