来个简单点:
Dim T1,T2 As String
T1 = "ywbh-" & Format(Date.today,"yyMMdd") & "-"
T2 = "[编号] like '" & T1 & "*'and [_Identify] < " & e.DataRow("_Identify")
Dim dr As DataRow = e.DataTable.Find(T2,"_Identify DESC")
If dr is Nothing then
e.DataRow("编号") = T1 & "001"
Else
e.DataRow("编号") = T1 & Format(Cint(dr("编号").substring(12,3))+1,"000")
End If