以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  窗口统计求助  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=5258)

--  作者:实话实说
--  发布时间:2009/12/3 23:52:00
--  窗口统计求助

这是表AfterSelRangeChange时间代码


if Forms("主窗口").Opened then
    Dim Sum,Average,Count As Integer
    With CurrentTable
        Sum = CurrentTable.Aggregate(AggregateEnum.Sum, .TopRow, .LeftCol, .BottomRow, .RightCol)
        Average = CurrentTable.Aggregate(AggregateEnum.Average, .TopRow, .LeftCol, .BottomRow, .RightCol)
        Count = CurrentTable.Aggregate(AggregateEnum.Count, .TopRow, .LeftCol, .BottomRow, .RightCol)
    End With
    Forms("主窗口").Controls("Label1").text ="    累计: " & Cstr(sum) & "     平均: " & Cstr(Average) & "     计数: " & Cstr(Count) & " "
end if

对身份证号码字段出错,其它正常,请帮忙改进

图片点击可在新窗口打开查看此主题相关图片如下:snap1.jpg
图片点击可在新窗口打开查看
[此贴子已经被作者于2009-12-3 23:52:33编辑过]

--  作者:实话实说
--  发布时间:2009/12/4 0:02:00
--  
身份证号码是字符型,
--  作者:mr725
--  发布时间:2009/12/4 0:09:00
--  
身份证号码 列有需要求累计值和平均值吗? 排除调这一列吧。
--  作者:czy
--  发布时间:2009/12/4 0:27:00
--  
if Forms("主窗口").Opened then
    Dim t as Table = CurrentTable
    For c As Integer = t.LeftCol To t.RightCol
        If c = 0 then
            Return
        End IF
        If t.Cols(c).IsNumeric = False Then
            Return
        End If
    Next
    Dim Sum,Average,Count As Integer
    Sum = CurrentTable.Aggregate(AggregateEnum.Sum, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol)
    Average = CurrentTable.Aggregate(AggregateEnum.Average, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol)
    Count = CurrentTable.Aggregate(AggregateEnum.Count, t.TopRow, t.LeftCol, t.BottomRow, t.RightCol)
    Forms("主窗口").Controls("Label1").text ="    累计: " & Cstr(sum) & "     平均: " & Cstr(Average) & "     计数: " & Cstr(Count) & " "
end if