Foxtable(狐表)用户栏目专家坐堂 → 索引和长度必须引用该字符串内的位置


  共有4743人关注过本帖树形打印复制链接

主题:索引和长度必须引用该字符串内的位置

帅哥哟,离线,有人找我吗?
季朝龙
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:83 积分:918 威望:0 精华:0 注册:2019/9/20 14:29:00
索引和长度必须引用该字符串内的位置  发帖心情 Post By:2019/12/12 15:18:00 [只看该作者]

.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2019.12.8.1
错误所在事件:表,更新数据,DataColChanged
详细错误信息:
调用的目标发生了异常。
索引和长度必须引用该字符串内的位置。
参数名: length

代码如下:

Dim cnt As Integer = Tables("更新数据").Rows.Count - 1
For i As Integer = 0 To cnt
    Dim n1 As String = Tables("更新数据").Rows(i).DataRow("料号1")
    Dim n2 As String = Tables("更新数据").Rows(i).DataRow("分群码")
    Dim dr0 As DataRow
    dr0 = DataTables("原始数据").Find("料号1 = '" & n1 & "' ","生产周期_天" ,0)
    Dim dr1 As DataRow
    dr1 = DataTables("原始数据").Find("料号1 = '" & n1 & "' ","生产周期_天" ,1)
    Dim dr2 As DataRow
    dr2 = DataTables("原始数据").Find("料号1 = '" & n1 & "' ","生产周期_天" ,2)
    If dr0 IsNot Nothing Then
        Tables("更新数据").Rows(i).DataRow("起始数量_台") = dr0.SQLGetValue("起始数量_台")
        Tables("更新数据").Rows(i).DataRow("截止数量_台") = dr0.SQLGetValue("截止数量_台")
        Tables("更新数据").Rows(i).DataRow("生产周期_天") = dr0.SQLGetValue("生产周期_天")
    End If
    Dim r As Row = Tables("更新数据").Rows(i)
    For j As Integer = 1 To 2
        If j = 1 Then
            If dr1 IsNot Nothing Then
                r.Clone
                Tables("更新数据").Current("起始数量_台") = dr1.SQLGetValue("起始数量_台")
                Tables("更新数据").Current("截止数量_台") = dr1.SQLGetValue("截止数量_台")
                Tables("更新数据").Current("生产周期_天") = dr1.SQLGetValue("生产周期_天")
            End If
        Else If j = 2 Then
            If  dr2 IsNot Nothing Then
                r.Clone
                Tables("更新数据").Current("起始数量_台") = dr2.SQLGetValue("起始数量_台")
                Tables("更新数据").Current("截止数量_台") = dr2.SQLGetValue("截止数量_台")
                Tables("更新数据").Current("生产周期_天") = dr2.SQLGetValue("生产周期_天")
            End If
        End If
    Next
Next

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:112390 积分:572218 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/12/12 15:31:00 [只看该作者]

错误所在事件:表,更新数据,DataColChanged

检查这个表事件

 回到顶部
帅哥哟,离线,有人找我吗?
季朝龙
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:83 积分:918 威望:0 精华:0 注册:2019/9/20 14:29:00
  发帖心情 Post By:2019/12/12 15:40:00 [只看该作者]

我重置列的时候没有问题的,只有单机窗口按钮时才出现问题

表事件代码如下,您帮忙看看那里出问题了
If e.DataCol.Name = "料号" Then
    If e.DataRow("分群码说明").Substring(0,2) = "板卡"
        Dim n As Integer = e.DataRow("品名").IndexOf("组件")
        If n = -1 Then
            e.DataRow("分类") = "其他板卡组件"
        Else
            e.DataRow("分类") = e.DataRow("品名").Substring(n-2,2)
        End If
    Else If e.DataRow("分群码说明").Substring(0,2) = "成品" Then
        e.DataRow("分类") = "成品"
    Else If e.DataRow("分群码说明").Substring(0,2) = "裸机" Then
        e.DataRow("分类") = "裸机"
    Else If e.DataRow("分群码说明").Substring(0,2) = "辅料" Then
        e.DataRow("分类") = "辅料"
    Else If e.DataRow("分群码说明").Substring(0,2) = "组装" Then
        e.DataRow("分类") = "组装"
    Else
        e.DataRow("分类") = "其他"
    End If
    e.DataRow("料号1") = e.DataRow("料号").Substring(0,6) + e.DataRow("分类") 
End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:112390 积分:572218 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/12/12 16:03:00 [只看该作者]

Select Case e.DataCol.Name
    Case "分群码说明","品名"
        If e.DataRow.isnull("分群码说明") = False AndAlso e.DataRow("分群码说明").length >= 2
            If e.DataRow("分群码说明").Substring(0,2) = "板卡"
                Dim n As Integer = e.DataRow("品名").IndexOf("组件")
                If n = -1 Then
                    e.DataRow("分类") = "其他板卡组件"
                ElseIf 
                    e.DataRow("分类") = e.DataRow("品名").Substring(n-2,2)
                End If
            Else If e.DataRow("分群码说明").Substring(0,2) = "成品" Then
                e.DataRow("分类") = "成品"
            Else If e.DataRow("分群码说明").Substring(0,2) = "裸机" Then
                e.DataRow("分类") = "裸机"
            Else If e.DataRow("分群码说明").Substring(0,2) = "辅料" Then
                e.DataRow("分类") = "辅料"
            Else If e.DataRow("分群码说明").Substring(0,2) = "组装" Then
                e.DataRow("分类") = "组装"
            Else
                e.DataRow("分类") = "其他"
            End If
        End If
    Case "料号","分类"
        If e.DataRow.isnull("料号") = False AndAlso e.DataRow("分群码说明").length >= 6
            e.DataRow("料号1") = e.DataRow("料号").Substring(0,6) + e.DataRow("分类")
        Else
            e.DataRow("料号1") = e.DataRow("分类")
        End If
End Select

 回到顶部