VB编程,某次比赛,有7位裁判打分,得分去掉一个最高分,去掉一个最低分,求出选手的平均分
1个回答
展开全部
在窗体中做一个文本框,复制后粘贴7份(做成控件数组),Text1(0)~Text1(6)放裁判打分,最后一个放平均分:
Private Sub Command1_Click()
s = Val(Text1(0).Text)
Max = s
Min = s
For i = 1 To 6
x = Val(Text1(i).Text)
If x > Max Then Max = x
If x < Min Then Min = x
s = s + x
Next i
Text1(7).Text = (s - Max - Min) / 5
End Sub
Private Sub Command1_Click()
s = Val(Text1(0).Text)
Max = s
Min = s
For i = 1 To 6
x = Val(Text1(i).Text)
If x > Max Then Max = x
If x < Min Then Min = x
s = s + x
Next i
Text1(7).Text = (s - Max - Min) / 5
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询