以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  参数名: length  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=188201)

--  作者:edisontsui
--  发布时间:2023/9/7 10:58:00
--  参数名: length
If e.DataCol.name = "票号" Then
    If e.DataRow.isnull("票号") = False Then
        If e.DataRow("特采单") = False Then
            If e.DataRow("票号") = "" Then
                e.DataRow("生产票号") = Nothing
            Else
                If e.DataRow("票号").startswith("HL") Then
                    e.DataRow("生产票号") = e.DataRow("票号").SubString(2, 4) & "9260000"
                Else
                    If e.DataRow("票号").Length = 10 Then
                       \'e.DataRow("票号") = "0" & e.DataRow("票号") \'此句删除以保留当初输入的格式
                        e.DataRow("生产票号") = "0" & e.DataRow("票号")
                    End If
                    If e.DataRow("票号").Length = 11 Then
                        e.DataRow("生产票号") = e.DataRow("票号")
                    End If 
                    If e.DataRow("票号").Length = 13 Then
                        If dr("票号").startsWith("920FT") OrElse dr("票号").startsWith("926FT") Then
                            dr("生产票号") = dr("票号").Substring(5, 4) & dr("票号").Substring(0, 3) & dr("票号").Substring(9, 4)
                        End If
                    End If
                End If
            End If
        Else
            e.DataRow("生产票号") = e.DataRow("票号")
        End If
        e.DataRow.save
    end if
End If

上面那段 datacolchanged 代码,老是出现如下提示:

调用的目标发生了异常。
索引和长度必须引用该字符串内的位置。
参数名: length

应该就是红色那部分问题,因为我去除那段,就不会发生提示了。但是我看不出什么问题来。谢谢。



--  作者:有点蓝
--  发布时间:2023/9/7 11:09:00
--  
红色没有问题,倒是这里有问题

                If e.DataRow("piao号").startswith("HL") Then
if e.DataRow("piao号").length > 6
                    e.DataRow("生产piao号") = e.DataRow("piao号").SubString(2, 4) & "9260000"
end if
                Else

另外"生产piao号"后又触发了其它什么代码?


--  作者:edisontsui
--  发布时间:2023/9/7 13:27:00
--  
果然 "生产票号" 触发的其他代码有问题(我加了对字符长度的判断后就没事了)。