--
Dim t As Table = Forms("录入窗口").Controls("Table1").Table
For Each s As String In t.DataTable.SQLGetValues("mid(类别代码,1,2)","类别代码 is not null and len(类别代码) > 1")
\'Dim a As String = s.SubString(0,2)
Dim max As String = DataTables("商品信息").Compute("Max(商品代码)","商品代码 like \'" & s & "%\' ")
Dim id As Integer = 1
If max > "" Then
id = cint(max.SubString(2)) + 1
End If
For Each dr As DataRow In t.DataTable.Select("类别代码 like \'" & s & "%\'","")
dr("商品代码") = s & Format(id,"000000")
id += 1
Next
Next