Option Base 1
Dim a(20, 5) As Integer 二维数组
Private Sub Command1_Click()
Open & "\" For Input As #1
For i = 1 To 20
For j = 1 To 5
Input #1, a(i, j) 读取文件存入到二维数组中
Text1 = Text1 + Str(a(i, j)) + Space(2)
Next j
Text1 = Text1 + Chr(13) + Chr(10)
Next i
Close #1
End Sub
Private Sub Command2_Click()
Dim x, y As Integer
x = 0
For i = 1 To 20
y = a(i, 1) 定义第一个数为最小值
For j = 2 To 5
If y > a(i, j) Then y = a(i, j) 求最小值
Next j
x = x + y 对每行的最小值求和
Next i
x = x / 20 求最小值的平均数
= x
End Sub
Private Sub Form_Unload(Cancel As Integer)
Open & "\" For Output As #1
Print #1,
Close #1
End Sub
vb 求平均值 来自淘豆网m.daumloan.com转载请标明出处.