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)