写成一个内部函数来用吧,毕竟自增编号用到的情况挺多。
Dim dt As DataTable = DataTables(args(0)) '表名 Dim drName As String = args(1) '列名 Dim left As String = args(2) '左边 Dim fomart As String = args(3) '格式 Dim max As String Dim idx As Integer max = dt.Compute("Max(" & drName & ")") If max > "" Then idx = CInt(max.SubString(left.Length, fomart.Length)) + 1 Else idx = 1 End If Return left & Format(idx, fomart)
然后,调用函数。
Dim idx As String = Functions.Execute("函数名", "表名", "列名", "WT", "000000") MessageBox.Show(idx)
|