DataTables("订单明细表").StopRedraw
Dim dt As DataTable = DataTables("订单明细表")
Dim dat As List(of String) =dt.GetValues("订单日期")
Dim d1,d2 As Date
Dim Days As Integer
For Each mn As String In dat
Dim y As String = cdate(mn).year
Dim m1 As Integer = cdate(mn).month
d1= cdate(mn).AddMonths(-1)
days = Date.DaysInMonth(d1.year,d1.Month)
d1 = d1.Adddays(days - d1.day)
d2 = d1.AddMonths(1)
days = Date.DaysInMonth(d2.year,d2.Month)
d2 = d2.Adddays(days - d2.day).adddays(1)
Dim m As String = Format(m1,"00")
Dim z As String = y & m
Dim drs As List(of DataRow)
drs = DataTables("订单明细表").Select("[订单日期] > #" & d1 & "# And [订单日期] < #" & d2 & "#")
For Each r As DataRow In drs
Dim sum As Integer
sum = sum+1
Dim sum1 As String = format(sum,"00000")
r("订单编号") = z & "-" & sum1
Next
Next
DataTables("订单明细表").ResumeRedraw
[此贴子已经被作者于2020/3/14 16:06:51编辑过]