1516西甲助攻:vb代码问题-请指教

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/06 02:29:52
Option Base 1
Dim score As Variant
Private Sub Form_Load()
Label1.Caption = "单击“查找”按钮开始查找最高分和最低分"
score = Array(89, 96, 81, 67, 79, 90, 63, 85, 95, 83)
End Sub
Private Sub command1_click()
Dim max As Integer, min As Integer
max = score(1) '设定初值
min = score(1)
For i = 2 To 10
If max < score(i) Then '找最高分
max = score(i)
End If
Next i
score(i)是什么意思 怎么求出最大值的 谢谢

i是指数组的任意一个下标
score(i)指数组中的某个元素,和max比较的意思就是让数组中的每个元簇和max比较,就能找出最大值。

是数组成员。
按顺序与max比较,并把大的一个赋值给max,然后继续循环