vb 总是提示索引超出了数组界限
Dima(7)AsIntegerDimiAsIntegera(0)=1a(1)=2a(2)=2a(3)=4a(4)=5a(5)=6a(6)=7a(7)=8Fori=0To...
Dim a(7) As Integer
Dim i As Integer
a(0) = 1
a(1) = 2
a(2) = 2
a(3) = 4
a(4) = 5
a(5) = 6
a(6) = 7
a(7) = 8
For i = 0 To 7
If a(i) < a(i + 1) Then
a(i) = a(i + 1)
Else
a(i) = a(i)
End If
Next i
TextBox50.Text = a(i)
求大神解答 展开
Dim i As Integer
a(0) = 1
a(1) = 2
a(2) = 2
a(3) = 4
a(4) = 5
a(5) = 6
a(6) = 7
a(7) = 8
For i = 0 To 7
If a(i) < a(i + 1) Then
a(i) = a(i + 1)
Else
a(i) = a(i)
End If
Next i
TextBox50.Text = a(i)
求大神解答 展开
1个回答
展开全部
For i = 0 To 7
If a(i) < a(i + 1) Then
a(i) = a(i + 1)'定义时,数组下标最大为7,而这里,i=7时,a(i+1)就是a(8)了。不是吗?
Else
a(i) = a(i)
End If
Next i
If a(i) < a(i + 1) Then
a(i) = a(i + 1)'定义时,数组下标最大为7,而这里,i=7时,a(i+1)就是a(8)了。不是吗?
Else
a(i) = a(i)
End If
Next i
追问
a(0) = Val(TextBox59.Text)
a(1) = Val(TextBox60.Text)
谢谢,我想再问问,我把数字换成文本框的值,TextBox50.Text就只显示0,如果定义数字,就会显示数字,这是怎么回事
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询