以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]报错,状态栏3自动计算上  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=32068)

--  作者:jijianjsj
--  发布时间:2013/4/25 11:02:00
--  [求助]报错,状态栏3自动计算上


图片点击可在新窗口打开查看此主题相关图片如下:未命名.bmp
图片点击可在新窗口打开查看

 

模仿原有系统菜单做的状态栏3自动计算报错,上图是什么原因。


--  作者:Bin
--  发布时间:2013/4/25 11:03:00
--  
索引超出范围了.把你代码发上来看看.代码有问题.
--  作者:jijianjsj
--  发布时间:2013/4/25 11:09:00
--  
SystemIdle 事件:
If CurrentTable Is Nothing Then
    Return
End If
\'以下代码用于在状态栏显示自动计算结果,如果不需要自动计算,可删除这一段
Dim t As Table = CurrentTable
If Vars("SysUpdateAggregate")
    If Windows.Forms.Control.MouseButtons <> Windows.Forms.MouseButtons.None OrElse Windows.Forms.Control.ModifierKeys <> Windows.Forms.Keys.None Then
        Return
    End If
    Dim Str1 As String = ""
    Vars("SysUpdateAggregate") = False
    Str1 = Str1 & "计数:" & t.Aggregate(AggregateEnum.Count, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    Str1 = Str1 & "累计:" & t.Aggregate(AggregateEnum.Sum, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    Str1 = Str1 & "平均:" & t.Aggregate(AggregateEnum.Average, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol) & " "
    RibbonMenu.StatusBar.Message3 = Str1
End If


AfterSelRangeChange事件:

Dim t As Table
RibbonMenu.StatusBar.Message3 = ""
Vars("SysUpdateAggregate") = False
If e.Table IsNot CurrentTable OrElse CurrentTable Is Nothing Then
    Return
Else
    t = CurrentTable
End If
If t.TopRow = t.BottomRow AndAlso t.LeftCol = t.RightCol Then
    Return
End If
For c As Integer = t.LeftCol To t.RightCol 
    If c < 1 Then
        Continue For
    End If
    If t.Cols(c).IsNumeric = False Then
        Return
    End If
Next
Vars("SysUpdateAggregate") =  True

--  作者:Bin
--  发布时间:2013/4/25 11:12:00
--  
看上去没发生问题啊. 把文件发上来看看
--  作者:jijianjsj
--  发布时间:2013/4/25 14:07:00
--  
重启一下电脑又好了,唉,莫名其妙~!
--  作者:铜豌豆之首
--  发布时间:2017/4/1 14:26:00
--  
If CurrentTable Is Nothing Then
    Return
End If
Dim t As Table = CurrentTable
If Vars("SysUpdateAggregate")
    If Windows.Forms.Control.MouseButtons <> Windows.Forms.MouseButtons.None OrElse Windows.Forms.Control.ModifierKeys <> Windows.Forms.Keys.None Then
        Return
    End If
    Dim Str1 As String = ""
    Vars("SysUpdateAggregate") = False
老师能否详解一下上面的代码,无论是帮助还是站内信息,都看了好几遍,还是理解不了,特别是有底纹的地方

--  作者:有点蓝
--  发布时间:2017/4/1 15:32:00
--  
If Vars("SysUpdateAggregate") \'如果变量值为true    

If Windows.Forms.Control.MouseButtons <> Windows.Forms.MouseButtons.None OrElse Windows.Forms.Control.ModifierKeys <> Windows.Forms.Keys.None Then \'如果鼠标按钮被按住或者键盘功能键被按住       
Return   
End If    
Dim Str1 As String = ""    
Vars("SysUpdateAggregate") = False \'把变量值为改为false。避免重复运行