Foxtable(狐表)用户栏目专家坐堂 → [求助]索引超出范围。必须为非负值并小于集合大小。 参数名: index【已结】


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

主题:[求助]索引超出范围。必须为非负值并小于集合大小。 参数名: index【已结】

帅哥哟,离线,有人找我吗?
无我是天机
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:233 积分:2602 威望:0 精华:0 注册:2013/9/2 23:31:00
[求助]索引超出范围。必须为非负值并小于集合大小。 参数名: index【已结】  发帖心情 Post By:2016/4/18 16:28:00 [只看该作者]

设计了一个窗口,窗口上面放了个按钮,点击此按钮后对一张表数据进行计算,最后生成一张统计表。现在的问题是:窗口运行正常,点击按钮后也能正常弹出统计表。但是从统计表再点回该窗口的时候,就不停的报“索引超出范围。必须为非负值并小于集合大小。 参数名: index ”错误,从统计表点到其他界面又没这个问题。因为不停的报这个错误,也没办法看清楚报错界面上具体的那个事件引起的!请老师们指点一下,是否有其他办法调试?
[此贴子已经被作者于2016/4/19 15:26:55编辑过]

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/4/18 16:31:00 [只看该作者]

首先,升级到最新版。

 

报这个错一般是你的代码和系统的SystemIdle事件有冲突。

 

如果你窗口上有table控件,而且不是副本表,那么你窗口的属性->所有者表,就不能是这个表。


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


加好友 发短信
等级:童狐 帖子:233 积分:2602 威望:0 精华:0 注册:2013/9/2 23:31:00
  发帖心情 Post By:2016/4/18 17:50:00 [只看该作者]

感谢红袍老师。现在确定是“报这个错一般是你的代码和系统的SystemIdle事件有冲突。”引起的,刚把该事件中的代码全部注销再测试,没有这个问题了。SystemIdle事件中以下代码有问题:
Dim t As Table = CurrentTable   
If t.Current Is Nothing Then
    Return
End If
If SystemMenu = False AndAlso  t.Cols(t.Colsel).IsNumeric  Then
    Dim tgbn As RibbonMenu.ToggleButton = RibbonTabs("Common").Groups("Aggregate").Items("Aggregate")
    If  tgbn.Pressed  Then
        With CurrentTable
            Dim str1 As String = ""
            Dim tbn As RibbonMenu.ToggleButton
            Dim cbx As RibbonMenu.Checkbox
            Dim itm As RibbonMenu.RibbonItem
            For Each itm In RibbonTabs("Common").Groups("Aggregate").Items
                Select Case itm.Name
                    Case "Count"
                        cbx = itm
                        If cbx.Checked Then
                            Str1 = Str1 & "计数:" & t.Aggregate(AggregateEnum.Count, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
                        End If
                    Case "Sum"
                        cbx = itm
                        If cbx.Checked Then
                            Str1 = Str1 & "累计:" & t.Aggregate(AggregateEnum.Sum, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
                        End If
                    Case "Average"
                        cbx = itm
                        If cbx.Checked Then
                            Str1 = Str1 & "平均:" & t.Aggregate(AggregateEnum.Average, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
                        End If
                    Case "Max"
                        cbx = itm
                        If cbx.Checked Then
                            Str1 = Str1 & "最大:" & t.Aggregate(AggregateEnum.Max, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
                        End If
                    Case "Min"
                        cbx = itm
                        If cbx.Checked Then
                            Str1 = Str1 & "最小:" & t.Aggregate(AggregateEnum.Min, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
                        End If
                    Case "Var"
                        tbn = itm
                        If tbn.Pressed Then
                            Str1 = Str1 & "标准差:" & t.Aggregate(AggregateEnum.Std, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
                        End If
                    Case "VarPop"
                        tbn = itm
                        If tbn.Pressed Then
                            Str1 = Str1 & "总体标准差:" & t.Aggregate(AggregateEnum.StdPop, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
                        End If
                    Case "Std"
                        tbn = itm
                        If tbn.Pressed Then
                            Str1 = Str1 & "方差:" & t.Aggregate(AggregateEnum.Var, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
                        End If
                    Case "StdPop"
                        tbn = itm
                        If tbn.Pressed Then
                            Str1 = Str1 & "总体方差:" & t.Aggregate(AggregateEnum.VarPop, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
                        End If
                End Select
            Next
            StatusBar.Message3 = Str1
        End With
    End If
End If
[此贴子已经被作者于2016/4/18 17:51:35编辑过]

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/4/18 17:53:00 [只看该作者]

你尝试多加一些判断

 

Dim t As Table = CurrentTable

If SystemMenu = False AndAlso t.Current IsNot Nothing AndAlso  t.Cols(t.Colsel).IsNumeric  Then

 

实在不行,做个对应的例子发上来看看。


 回到顶部