Dim dt As DataTable = DataTables("收支交易流水")
Dim max As String
Dim idx As Integer
Dim xrq As String = Format(Date.Today,"yyyyMMdd")
Dim max As String
max = dt.Compute("Max(单号)","单号 like 'HD & xrq & %'")
If max > "" Then '如果存在最大编号
idx = CInt(max1.SubString(10)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
For Each dr1 As DataRow In dt.Select("单号 is null")
Dim str As String = "HD" & xrq & Format(idx,"0000")
Dim fdr As DataRow = dt.find("单号 ='" & str & "'")
If fdr Is Nothing
dr1("单号") = str
End If
idx += 1
Next
代码哪有问题?自动编号为什么隔一行已添加呢
此主题相关图片如下:截图00.jpg
![dvubb 图片点击可在新窗口打开查看](UploadFile/2020-2/202021319593549068.jpg)
[此贴子已经被作者于2020/2/13 19:59:37编辑过]