以文本方式查看主题

-  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=80384)

--  作者:lfxxdt
--  发布时间:2016/1/21 16:27:00
--  平均值
一个行中有10个数据,我想计算这10个数据的平均值,应该如何编写代码。
--  作者:大红袍
--  发布时间:2016/1/21 16:31:00
--  

分别取出,然后计算

 

Dim cs() As String = {"第一列", "第二列"}
dim sum as double = 0
for each c as string in cs
    sum += val(tables("表A").Current(c))
Next
msgbox(sum)
msgbox(sum/cs.length)


--  作者:lfxxdt
--  发布时间:2016/1/21 16:52:00
--  
运行后显示这样的错误提示:Exception has been thrown by the target of an invocation.
--  作者:大红袍
--  发布时间:2016/1/21 17:05:00
--  

说明你此表一行数据都没有。代码没问题的。