老师您好! 我有一个表的编号列格式是这样的:其中两行内容:wd-魏德曼-20200709-0474和wd-魏德曼-20200707-0463,我想在增加行时,取这列中所有编号的后四位中的最大值加1,做为新行的编号后四位。我写的代码是这样的,但不执行。Select e.DataCol.Name
Case "接单日期","客户"
If e.DataRow.IsNull("接单日期") OrElse e.DataRow.IsNull("客户") Then
e.DataRow("编号") = Nothing
Else
Dim d As Date = e.DataRow("接单日期")
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim bh As String = "wd-" & e.DataRow("客户") & "-" & Format(d,"yyyyMMdd") & "-" '生成编号的前缀
If e.DataRow("编号").StartsWith(bh) = False '如果单据编号前缀不符
Dim max As String
Dim idx As Integer
Dim flt As String
max = e.DataTable.Compute(Max.substring(e.DataRow("编号").length-3,4))
If max > "" Then
idx=cint(max)+1
Else
idx = 1
End If
e.DataRow("编号") = bh & Format(idx,"0000")
End If
End If
End Select
谢谢!