📄 form0606.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "计算平均成绩"
ClientHeight = 3780
ClientLeft = 60
ClientTop = 450
ClientWidth = 4740
LinkTopic = "Form1"
ScaleHeight = 3780
ScaleWidth = 4740
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text3
Height = 495
Left = 2400
TabIndex = 6
Top = 240
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "计算"
Height = 495
Left = 1800
TabIndex = 4
Top = 3000
Width = 1335
End
Begin VB.TextBox Text2
Height = 495
Left = 2400
TabIndex = 3
Top = 2160
Width = 1455
End
Begin VB.TextBox Text1
Height = 495
Left = 2400
TabIndex = 0
Top = 1200
Width = 1455
End
Begin VB.Label Label3
Caption = "输入学生数"
Height = 495
Left = 960
TabIndex = 5
Top = 360
Width = 1215
End
Begin VB.Label Label2
Caption = "数学平均成绩"
Height = 375
Left = 960
TabIndex = 2
Top = 2280
Width = 1335
End
Begin VB.Label Label1
Caption = "语文平均成绩"
Height = 375
Left = 960
TabIndex = 1
Top = 1200
Width = 1335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 1
Private Sub Command1_Click()
'单击计算按钮
Dim Score1() As Single, Score2() As Single
Dim i As Integer, j As Integer
Dim n As Integer
'输入分数
ReDim Score1(8): ReDim Score2(8)
Score1(1) = 98: Score2(1) = 84
Score1(2) = 82: Score2(2) = 86
Score1(3) = 76: Score2(3) = 79
Score1(4) = 66: Score2(4) = 72
Score1(5) = 88: Score2(5) = 84
Score1(6) = 82: Score2(6) = 76
Score1(7) = 75: Score2(7) = 79
Score1(8) = 60: Score2(8) = 70
n = Val(Text3.Text)
Text1.Text = Int(Average(Score1, n) * 100) / 100
Text2.Text = Int(Average(Score2, n) * 100) / 100
End Sub
Private Function Average(s() As Single, m As Integer) As Single
' 求平均成绩子函数
Dim i As Integer
Dim Aver As Single, Sum As Single
ReDim Preserve s(m)
For i = 1 To m
Sum = Sum + s(i)
Next
Aver = Sum / m
Average = Aver
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -