Dim d As Date = Date.Today Dim max As String Dim idx As Integer Dim flt As String Dim bh As String =Format(d,"yyyy") flt = "编号 like '" & bh & "%'" 'Output.Show(flt) 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("编号") ="CG" & bh & Format(idx,"000")