form1.frm
来自「蒋加伏主编VB程序设计第四版PPT及全部课本源码 北京邮电大学出版社 」· FRM 代码 · 共 107 行
FRM
107 行
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()
n = 0: m = 0: total = 0 '变量清0
Start: '标号
Score = Val(InputBox("请输入分数(-1结束)", "输入数据"))
If Score < 0 Or Score > 100 Then
GoTo Finish '输入小于0或大于100时结束
Else
total = total + Score '累计总分
n = n + 1 '统计总人数
If Score >= 60 Then m = m + 1 '统计及格人数
End If
GoTo Start '无条件转移到Start标号
Finish: '标号
End Sub
'显示结果
Private Sub Command2_Click()
Text1.Text = Str$(n)
Text2.Text = Str$(m)
Text3.Text = Str$(total / n)
End Sub
Private Sub Command3_Click()
End
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?