请vb先辈帮忙

来源:百度知道 编辑:UC知道 时间:2024/05/14 15:05:00
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)是什么意思 怎么找到最大数的 谢谢

score(i)是数组,存放了(89, 96, 81, 67, 79, 90, 63, 85, 95, 83)
怎么找到最大数的
max = score(1) '设定初值
min = score(1)
For i = 2 To 10
If max < score(i) Then '找最大数
max = score(i)
是同过这段代码找出的, MAX 里存放了 89 ,用89 有与score(i)里的值比较,当score(i)的值大于MAX 里的 也就是89 那么就把 score(i)的值给 MAX ,这时候MAX 里的值是最大的
这样说不知道你明白吗
GOOD LUCK

score(1)=89 score是个数组,score(1)是第一个元素的值
score = Array(89, 96, 81, 67, 79, 90, 63, 85, 95, 83)
创建的
用一个for循环,max存最大数
先让max=score(1)
如果从score(2)开始,如果第几个值比max大,max就改为score(几)
到score(10)结束

score(i)就是 Array(89, 96, 81, 67, 79, 90, 63, 85, 95, 83) ,即score(1)="89"、score(2)="96"……;
首先程序先把第一个数89存在max里面,然后,跟后面的比较,如果比max大的话就把max换成这个数。最后就得出最大数了。

score(i) 就是数组 score 的第i 个数据 即如果i= 2 score(i)= 96
最大值:先是把score数组的第一个数放在 max 中,然后通过for 语句循环,碰到数据比max 大的,就把大的放到 max 中,这样,循环结束时,max 中的值肯定是数组中最大的