For Each dr As DataRow In DataTables("成绩库").DataRows
If dr.IsNull("类别代码") Then
dr("编号") = Nothing
Else
Dim dj As String = dr("等级1")
Dim lb As String = dr("类别代码")
Dim max As String
Dim idx As Integer
Dim s As String = dr("编号")
max = dr.DataTable.Compute("Max(编号)", "类别代码 = '" & lb & "'") '取得类别该等级的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(5,3)) + 1 '获得最大编号的后三位顺序号,并加1(从第6个字符开始取3个字符)
Else
idx = 1 '否则顺序号等于1
End If
dr("编号") = lb & Format(idx,"000")
End If
Next
红色代码表示从第6个字符开始取3个字符,我要不计前面有多少个字符,只取最后3个字符,怎么修改红色代码?谢谢!