-- 代码有什么问题么?为什么 编号都是001 不自动增加呢?
If e.DataCol.Name = "time" Then
If e.DataRow.IsNull("time") Then
e.DataRow("danhao") = Nothing
Else
Dim bh As String = Format(e.DataRow("time"),"yyyyMMdd") \'取得danhao的8位前缀
If e.DataRow("danhao").StartsWith(bh) = False \'如果danhao的前8位不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(danhao)","time = #" & e.DataRow("time") & "# And [_Identify] <> " & e.DataRow("_Identify")) \'取得该天的最大danhao
If max > "" Then \'如果存在最大danhao
idx = CInt(max.Substring(9,3)) + 1 \'获得最大danhao的后三位顺序号,并加1
Else
idx = 1 \'否则顺序号等于1
End If
e.DataRow("danhao") = bh & "-" & Format(idx,"000")
End If
End If
End If
[此贴子已经被作者于2016/5/24 14:26:33编辑过]