以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  请问如何实现去除最高、最低,次高、次低*0.5计算  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=77318)

--  作者:老柴
--  发布时间:2015/11/16 13:51:00
--  请问如何实现去除最高、最低,次高、次低*0.5计算
请问一下,如何实现一个表中A列数值有7个以下数值时B列按(sum[A]-MAX[A]-MIN[A])/(N-2),A列数值多余7个时B列计算为(sum[A]-MAX[A]-MIN[A]+次高[A]*0.5+次低[A]*0.5)/(N-3).
--  作者:大红袍
--  发布时间:2015/11/16 14:18:00
--  

Dim A As String = "1,2,3,4,5,6,7"
Dim ary() As String = A.Split(",")
Dim nary(ary.Length-1) As Integer

Dim sum As Double = 0
For i As Integer = 0 To nary.length - 1
    sum += val(ary(i))
    nary(i) = ary(i)
Next

array.sort(nary)

Dim B As Double
If ary.Length <= 7 Then
    B = (sum-nary(nary.length-1)-nary(0)) / (nary.length-2)
Else
    B = (sum-nary(nary.length-1)-nary(0)+nary(nary.length-2)*0.5+nary(1)*0.5) / (nary.length-3)
End If

msgbox(B)


--  作者:老柴
--  发布时间:2015/11/16 14:28:00
--  
谢谢