vb中显示“下标越界”是什么意思?为什么我这个程序总会显示下标越界?谢谢
当j=10时,a(j+1)=a(11),这就超出数组a的下标范围了,所以提示你“下标越界”。应该把排序的代码改为:PrivateSubCommand2_Click()Pr...
当j=10时,a(j + 1)=a(11),这就超出数组a的下标范围了,所以提示你“下标越界”。应该把排序的代码改为:
Private Sub Command2_Click()
Print "排序后:"
For i = 1 To 9
For j = i + 1 To 10
If a(i) < a(j) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next j
Next i
For i = 1 To 10
Print a(i);
Next i
End Sub 展开
Private Sub Command2_Click()
Print "排序后:"
For i = 1 To 9
For j = i + 1 To 10
If a(i) < a(j) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next j
Next i
For i = 1 To 10
Print a(i);
Next i
End Sub 展开
1个回答
展开全部
当j=10时,a(j + 1)=a(11),这就超出数组a的下标范围了,所以提示你“下标越界”。应该把排序的代码改为:
Private Sub Command2_Click()
Print "排序后:"
For i = 1 To 9
For j = i + 1 To 10
If a(i) < a(j) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next j
Next i
For i = 1 To 10
Print a(i);
Next i
End Sub
Private Sub Command2_Click()
Print "排序后:"
For i = 1 To 9
For j = i + 1 To 10
If a(i) < a(j) Then
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next j
Next i
For i = 1 To 10
Print a(i);
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询