vb程序提示下标越界, 提示是这里出错 myarray(p) = myarray(j), 可是我又不知道怎么改,求高手指点! 5
OptionExplicitOptionBase1PrivateSubCommand1_Click()Dimmyarray(7)AsIntegerDimi%Fori=1T...
Option Explicit
Option Base 1
Private Sub Command1_Click()
Dim myarray(7) As Integer
Dim i%
For i = 1 To 7
myarray(i) = Rnd() * 30
Print myarray(i)
Next i
Print
Dim j%, tmp%, p%
For i = 1 To 7
p = i
For j = i + 1 To 7
If myarray(j) < myarray(i) Then
p = j
End If
Next j
If p <> i Then
tmp = myarray(p)
myarray(p) = myarray(j)
myarray(j) = tmp
End If
For j = 1 To 7
Print myarray(j)
Next j
Print
Next i
End Sub 展开
Option Base 1
Private Sub Command1_Click()
Dim myarray(7) As Integer
Dim i%
For i = 1 To 7
myarray(i) = Rnd() * 30
Print myarray(i)
Next i
Dim j%, tmp%, p%
For i = 1 To 7
p = i
For j = i + 1 To 7
If myarray(j) < myarray(i) Then
p = j
End If
Next j
If p <> i Then
tmp = myarray(p)
myarray(p) = myarray(j)
myarray(j) = tmp
End If
For j = 1 To 7
Print myarray(j)
Next j
Next i
End Sub 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询