Dim d As Date = Date.Today Dim max As String Dim idx As Integer Dim flt As String Dim bh As String = "CG" & Format(d,"yyyy") flt = "编号 like '" & bh & "%'" max = e.DataTable.Compute("Max(编号)",flt) If max > "" Then '如果存在最大 idx = CInt(max.Substring(max.Length-3,3)) + 1 Else idx = 1 '否则顺序号等于1 End If e.DataRow("编号") = bh & Format(idx,"000")