【VB开源代码栏目提醒】:网学会员VB开源代码为您提供5.2.1.frm参考,解决您在5.2.1.frm学习中工作中的难题,参考学习。
VERSION 5.00
Begin VB.Form Form2
Caption = "Form2"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form2"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 735
Left = 1440
TabIndex = 0
Top = 960
Width = 1095
End
End
Attribute
VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim a(1 To 5) As Single
'定义一维静态数组
Dim sum, avg As Single
Dim i As Integer
For i = 1 To 5
'输入成绩
a(i) = InputBox("请输入第" & i & "个学生的成绩")
Next
For i = 1 To 5
'求数组元素和
sum = sum + a(i)
Next
avg = sum / 5
'求均值
Text1.Text = avg
End Sub