
此主题相关图片如下:截图1.jpg

代码如下 是在命令窗口试验的
Dim s As String = Tables("综合部物品分类设置_综合部物品分类设置Table1").current("分类编号")
Dim s1 As String
Dim i As Integer = s.LastIndexOf(".")
s1 = s.SubString(0,i)
output.show(s1)
Dim s2,s3 ,s4 As String
Dim dr,dr1 As DataRow
Dim n,n1 As Integer
Dim dt As DataTable = Tables("综合部物品分类设置_综合部物品分类设置Table1").DataTable
dr = dt.AddNew
s2 = "SubString(分类编号, 1, " & i & ") = '" & s1 & "' And len(分类编号) = " & s.Length
dr1 = dt.Find(s2)
s3= s1 & "."
If dt.DataRows.count =1 OrElse dr1 Is Nothing Then 'dt.DataRows.count =1 是因为有dr = dt.AddNew,增加了一行
dr("分类编号") = s3 & "01"
Else
For Each dr In dt.Select(s2)
n=dr1("分类编号").Substring(s1.Length + 1)
n1=iif(n1<n,n,n1)
Next
End If
output.show(
n1)
按道理应该是截图上的 01.03.10 中的10
[此贴子已经被作者于2012-11-20 14:13:59编辑过]