📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "例[5-9] 成绩统计"
ClientHeight = 1800
ClientLeft = 60
ClientTop = 345
ClientWidth = 3945
LinkTopic = "Form1"
ScaleHeight = 1800
ScaleWidth = 3945
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "结束"
Height = 400
Left = 2640
TabIndex = 7
Top = 1080
Width = 975
End
Begin VB.CommandButton Command1
Caption = "开始"
Height = 400
Left = 2640
TabIndex = 6
Top = 360
Width = 975
End
Begin VB.TextBox Text3
Height = 400
Left = 1080
TabIndex = 5
Top = 1200
Width = 1215
End
Begin VB.TextBox Text2
Height = 400
Left = 1080
TabIndex = 4
Top = 720
Width = 1215
End
Begin VB.TextBox Text1
Height = 400
Left = 1080
TabIndex = 3
Top = 240
Width = 1215
End
Begin VB.Label Label3
Caption = "总平均分"
Height = 285
Left = 120
TabIndex = 2
Top = 1320
Width = 1215
End
Begin VB.Label Label2
Caption = "及格人数"
Height = 285
Left = 120
TabIndex = 1
Top = 840
Width = 1215
End
Begin VB.Label Label1
Caption = "学生人数"
Height = 285
Left = 120
TabIndex = 0
Top = 360
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Dim n As Integer, m As Integer, total As Single
Private Sub Command1_Click()
Dim Score As Single, PassN As Integer, n As Integer
Dim i As Integer, Sum As Single
Sum = 0: PassN = 0: n = 0
For i = 1 To 50 ' 统计人数大于50时停止循环
Score = InputBox("请输入学生成绩")
If Score < 0 Then ' 输入负数时停止循环
Exit For
Else
If Score >= 60 Then PassN = PassN + 1 '统计及格人数
n = n + 1 '统计总人数
Sum = Sum + Score '统计总分
End If
Next i
Text1.Text = Str$(n)
Text2.Text = Str$(PassN)
Text3.Text = Str$(Sum / n)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -