VB画曲线这些后面语句哪里有问题,为啥出现越界错误
Option ExplicitPrivate Sub Command1_Click()
Dim i As Integer, n As Integer
Dim C(100, 2000) As Double
Dim xd As Double: Dim λ As Double: Dim Id As Double: Dim I1 As Double
Dim φ As Double: Dim ρ As Double: Dim L As Double: Dim C0 As Double
Dim K1 As Double: Dim K2 As Double: Dim Crd As Double
Dim a As Double, b As Double
L = 100
λ = 1
xd = 0.01
Id = 0.002
φ = 0.21
ρ = 2.65
C0 = 10
K1 = 0.1
K2 = 0.1
Crd = 1
b = K1 / K2
a = b * Crd
For n = 0 To 1999 Step 1
If n = 0 Then
C(i, n) = 0
Else
For i = 1 To 100
If i = 1 Then
C(i, n + 1) = (1 + (λ / L) * (4 * C(2, n) - C(3, n)) / (2 * xd)) / (1 + (3 * λ / L) / (2 * xd))
ElseIf i = 100 Then
C(i, n + 1) = (4 * C(i - 1, n + 1) - C(i - 2, n + 1)) / 3
Else
I1 = Id / (1 + ((1 - φ) / φ) * ρ * (a / ((1 + b * C0 * C(i, n)) ^ 2)))
C(i, n + 1) = (C(i - 1, n + 1) * (λ / (L * xd ^ 2) + 1 / (2 * xd)) + C(i, n) * (-λ / (L * xd ^ 2) + 1 / (xd * 2) + 1 / I1) + C(i + 1, n) * (λ / (L * xd ^ 2) - 1 / (2 * xd))) / (λ / (L * xd ^ 2) + 1 / (2 * xd) + 1 / I1)
End If
Next i
End If
Next n
With MSChart1 '设置MSChart1
.ColumnCount = 1 '图上只画一条曲线
.chartType = VtChChartType2dLine '设置图表类型为二维曲线;默认为直方图
.RowCount = 25 'X轴显示10个单位
End With
With MSChart1 ' 显示曲线
For n = 1 To 2000 Step 100
.Row = n * 0.002 ' 指定X轴的坐标
.RowLabel = n * 0.002 ' X轴标签
.Data = C(100, n) ' 与x对应的值
Next n
End With
End Sub
这些后面语句哪里有问题,为啥出现越界错误?