.NET Framework 版本:2.0.50727.5456
Foxtable 版本:2018.3.9.1
错误所在事件:cbb,AfterSelRangeChange
详细错误信息:
索引超出范围。必须为非负值并小于集合大小。
参数名: index
对应AfterSelRangeChange的代码
If MainTable.name = "cbb" Then
With e.NewRange
Dim t As Integer = .TopRow
Dim b As Integer = .BottomRow
If t >= 0 And b >= 0 Then
Dim p1 As Integer = Tables("cbb").Cols("含税销售额").Index '获得数量列的位置
Dim p2 As Integer = Tables("cbb").Cols("成本金额").Index '获得数量列的位置
Dim p3 As Integer = Tables("cbb").Cols("利润").Index '获得数量列的位置
Dim v1 As Double
v1 = Tables("cbb").Aggregate(AggregateEnum.Sum, .TopRow, p1, .BottomRow, p1)
Dim v2 As Double
v2 = Tables("cbb").Aggregate(AggregateEnum.Sum, .TopRow, p2, .BottomRow, p2)
Dim v3 As Double
v3 = Tables("cbb").Aggregate(AggregateEnum.Sum, .TopRow, p3, .BottomRow, p3)
Dim v4 As Double = v3/v1
StatusBar.Message2 = " 合计 销售:" & Format(v1,"########.##") & " 成本:" & Format(v2,"########.##") & " 利润:" & Format(v3,"########.##") & " 利润率:" & Format(v4,"Percent") & ""
End If
End With
End If
是否加了蓝色字体这个判断,都会出现此错误。
如何保证是非负呢?