[求助] 运行代码出现下标越界的错误提示,怎么解决
Private Sub Command1_Click()Dim m As Integer, n As Integer
Dim j As Integer, k As Integer
Dim i As Integer, Px(100) As Double
Dim pd(20) As Double
Dim md(20) As Double
Dim mx(100) As Double
For n = 1 To 18
pd(n) = 25
Next n
For n = 1 To 18
md(n) = 25 * 2.25 / Z(pd(n)) / 8.314 / 293 * 28 * 1000
Next n
For m = 1 To 98
Px(m) = 3
Next m
For n = 1 To 98
mx(n) = 3 * 0.07 / Z(Px(m)) / 8.314 / 293 * 28 * 1000
Next n
k = 0
aa: k = k + 1
j = 1
For j = 1 To 12
Do While pd(j) - Px(k) >= 1.25
md(j) = md(j) - 0.01
pd(j) = md(j) * (1.00036 - 0.00276 * pd(j) + 0.000297905 * pd(j) * pd(j) - 0.000001584444 * pd(j) * pd(j) * pd(j)) * 8.314 * 293 / 2.25 / 28 / 1000 'Z(pd(j))
mx(k) = mx(k) + 0.01
Px(k) = mx(k) * (1.00036 - 0.00276 * Px(k) + 0.000297905 * Px(k) * Px(k) - 0.000001584444 * Px(k) * Px(k) * Px(k)) * 8.314 * 293 / 0.07 / 28 / 1000 'Z(pd(j)
If Px(k) >= 20 Then
GoTo aa
End If
Loop
Next j
Text35.Text = k
Text34.Text = Px(k)
For n = 1 To 10 Step 1
i = 3 * (n - 1) + 1
Controls("Text" & i).Text = pd(n)
'Print pd(n)
Next n
End Sub
Private Function Z(ByVal X As Double) As Double
Dim result As Double
result = 1.00036 - 0.00276 * X + 0.000297905 * X * X - 0.000001584444 * X * X * X '压缩系数拟合函数
Z = result
End Function