以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  判断开头  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=144421)

--  作者:455631117
--  发布时间:2019/12/19 14:15:00
--  判断开头
在窗口中做一个按钮,click事件中设置自动单号生成,部分代码如下:

Dim dh As String = Format(d1,"yyyyMMdd") \'取得编号的前八位,4位年,2位月,2位日
If Datatables("入库").DataRows("单号").StartsWith(dh) = False \'如果编号的前8位不符
    Dim max As String
    Dim idx As Integer
    max = DataTables("入库").Compute("Max(单号)","日期 = #" & d1 & "# and [_Identify] <> " & DataTables("入库").DataRows("_Identify")) \'取得该天的最大编号
    If max > "" Then \'如果存在最大编号
        idx = CInt(max.Substring(9,3)) + 1 \'获得最大编号的后三位顺序号,并加1
    Else
        idx = 1 \'否则编号等于1
    End If
    DataTables("入库").DataRows("单号") = dh & "-" & Format(idx,"000")
End If

提示StartsWith不是DataRow的成员,求助应该怎么解决

--  作者:有点蓝
--  发布时间:2019/12/19 14:33:00
--  
dim r as row = tables("入库").current
if r is nothing then return

Dim dh As String = Format(d1,"yyyyMMdd") \'取得编号的前八位,4位年,2位月,2位日
If r("单号").StartsWith(dh) = False \'如果编号的前8位不符
    Dim max As String
    Dim idx As Integer
    max = DataTables("入库").Compute("Max(单号)","日期 = #" & d1 & "# and [_Identify] <> " & r("_Identify")) \'取得该天的最大编号
    If max > "" Then \'如果存在最大编号
        idx = CInt(max.Substring(9,3)) + 1 \'获得最大编号的后三位顺序号,并加1
    Else
        idx = 1 \'否则编号等于1
    End If
    r("单号") = dh & "-" & Format(idx,"000")
End If