vb编程假设有6名(也可以是其它数字)裁判对参赛选手进行打分,要求分数控制在1~10之
1假设有6名(也可以是其它数字)裁判对参赛选手进行打分,要求分数控制在1~10之间。2在列表框或者组合框中给出最少3个预先设定的选手名称,并且可以添加、删除选手。3程序可...
1 假设有6名(也可以是其它数字)裁判对参赛选手进行打分,要求分数控制在1~10之间。
2 在列表框或者组合框中给出最少3个预先设定的选手名称,并且可以添加、删除选手。
3 程序可找出并显示最高分和最低分;
4 最后得分应为去掉最高分和最低分后的平均分,保留小数点后2位;
5 可以在一个较大窗体上显示选手名称和最高分、最低分、平均分。 展开
2 在列表框或者组合框中给出最少3个预先设定的选手名称,并且可以添加、删除选手。
3 程序可找出并显示最高分和最低分;
4 最后得分应为去掉最高分和最低分后的平均分,保留小数点后2位;
5 可以在一个较大窗体上显示选手名称和最高分、最低分、平均分。 展开
展开全部
Private Sub Command1_Click()
Dim MaxScore As Single, MinScore As Single, Score As Single, Flag As Boolean
Flag = True
For i = 0 To 9
If Text1(i).Text = "" Then
MsgBox "有裁判没有打分!"
Flag = False
Exit For
End If
Next i
If Flag Then
MaxScore = 0
MinScore = 10
For j = 0 To 9
Score = Score + Val(Text1(j).Text)
If Val(Text1(j).Text) > MaxScore Then MaxScore = Val(Text1(j).Text)
If Val(Text1(j).Text) < MinScore Then MinScore = Val(Text1(j).Text)
Next j
Score = Score - MaxScore - MinScore
Score = Score / 8
Label3.Caption = Format(MaxScore, "0.00")
Label4.Caption = Format(MinScore, "0.00")
Label6.Caption = Format(Score, "0.00")
Label3.Visible = True
Label4.Visible = True
Label6.Visible = True
End If
End Sub
Private Sub Command2_Click()
If MsgBox("确定要清除数据吗?", vbYesNo, "提示") = vbYes Then
For i = 0 To 9
Text1(i).Text = ""
Next i
Label3.Caption = ""
Label4.Caption = ""
Label6.Caption = ""
End If
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
List1.AddItem InputBox("请输入要添加的选手姓名:", "添加选手")
Label8.Caption = "共计" & List1.ListCount & "名选手"
End Sub
Private Sub Command5_Click()
If List1.ListIndex = -1 Then
MsgBox "请选择要删除的选手!"
Else
List1.RemoveItem List1.ListIndex
End If
Label8.Caption = "共计" & List1.ListCount & "名选手"
End Sub
Private Sub Form_Load()
List1.AddItem "王宏伟"
List1.AddItem "张 敏"
List1.AddItem "王曙光"
List1.AddItem "李晓妮"
Label8.Caption = "共计" & List1.ListCount & "名选手"
Label3.Visible = False
Label4.Visible = False
Label6.Visible = False
Label1(0).Left = 200
Label1(0).Top = 100
Me.AutoRedraw = True
For i = 1 To 9
Load Label1(i)
Label1(i).Visible = True
If i < 9 Then
Label1(i).Caption = "裁判 " & i + 1
Else
Label1(i).Caption = "裁判" & i + 1
End If
Label1(i).Left = 200
Label1(i).Top = 100 + i * 300
Next i
Text1(0).Left = 800
Text1(0).Top = 60
Text1(0).MaxLength = 5
Text1(0).Text = ""
For i = 1 To 9
Load Text1(i)
Text1(i).Visible = True
Text1(i).Left = 800
Text1(i).Top = 60 + i * 300
Text1(i).Text = ""
Next i
End Sub
Private Sub List1_Click()
Label9.Caption = List1.Text
End Sub
Private Sub Text1_Change(Index As Integer)
If Val(Text1(Index).Text) < 0 Or Val(Text1(Index).Text) > 10 Then
MsgBox "分数非法!"
Text1(Index).Text = ""
End If
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If (KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 46 Then
KeyAscii = 0
Beep
End If
End Sub
--
2022-12-05 广告
2022-12-05 广告
图形化编程简单理解为用积木块形式编程,scratch和python也是其中的一种,属于入门级编程,以其简单生动的画面获得无数学生的喜爱,深圳市创客火科技有限公司是一家做教育无人机的公司,旗下有编程无人机,积木无人机及室内外编队,每款飞机含有...
点击进入详情页
本回答由--提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询