VB下标越界
各位大佬,我运行为什么下面程序会出现下标越界,跪求答案Private Sub Command1_Click()
Dim a!, b!, c!
Dim i(1 To 6) As Single
Dim l(1 To 6) As Single
Dim h(1 To 6) As Single
Dim pd(1 To 6) As Single
Dim pc(1 To 6) As Single
Dim bg(1 To 6) As Single
For a = 1 To 6
i(a) = Val(InputBox("输入第" & a & "段线路坡度"))
l(a) = Val(InputBox("输入第" & a & "段线路长度"))
h(a) = Val(InputBox("输入第" & a & "段线路标高"))
Next a
c = 1
b = 1
Do While c < 7
pd(b) = (h(c + 1) - h(c)) * 1000 / (l(c) + l(c + 1))
If l(c) * Abs(pd(b) - i(c)) <= 2000 And l(c + 1) * Abs(pd(b) - i(c + 1)) <= 2000 Then
pd(b + 1) = (h(c + 2) - h(c)) * 1000 / (l(c) + l(c + 1) + l(c + 2))
If Abs(pd(b + 1) - i(c)) * l(c) <= 2000 And Abs(pd(b + 1) - i(c + 2)) * l(c + 2) <= 2000 And Abs(pd(b + 1) - i(c + 1)) * l(c + 1) <= 2000 Then
Label1.Caption = Label1.Caption & pd(b + 1) & vbCrLf
Label2.Caption = Label2.Caption & (l(c) + l(c + 1) + l(c + 2)) & vbCrLf
c = c + 3
b = b + 1
Else
Label1.Caption = Label1.Caption & pd(b) & vbCrLf
Label2.Caption = Label2.Caption & (l(c) + l(c + 1)) & vbCrLf
c = c + 2
b = b + 1
End If
Else
Label1.Caption = Label1.Caption & i(c) & vbCrLf
Label2.Caption = Label2.Caption & l(c) & vbCrLf
c = c + 1
b = b + 1
End If
Loop
End Sub