以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]自动编号问题  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=25759)

--  作者:13636600695
--  发布时间:2012/11/16 7:02:00
--  [求助]自动编号问题

下面这段代码不能自动计算出编号,请帮忙修改下,谢谢

Dim dt As DataTable = DataTables("表A")
Dim drName As String = "第一列"
Dim left As String = "SN"
Dim fomart As String = "0000"

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

msgbox(left &  Format(idx, fomart))