十万火急,马上要交了。。。关于子程序的调用
For I = 2 To NNBiaoJi: A1 = GCH_MIN(I)
If GCH(I, M(I)) > GCH(I, 1) Then
b = GCH(I, 1)
Else
b = GCH(I, M(I))
End If
Debug.Print "b = "; b
'二分法解能量方程
Z(I) = b
Call AERA(I)
Call SHUIWEI(Z)
FXB = FX
子程序:
Public Sub AERA(I)
W(I) = 0
X(I) = 0
For J = 1 To M(I) - 1
If GCH(I, J) <= Z(I) And GCH(I, J + 1) <= Z(I) Then
W(I) = W(I) + (Z(I) - (GCH(I, J + 1) + GCH(I, J)) / 2) * (AX(I, J + 1) - AX(I, J))
X(I) = X(I) + ((GCH(I, J + 1) - GCH(I, J)) ^ 2 + (AX(I, J + 1) - AX(I, J)) ^ 2) ^ (1 / 2)
ElseIf GCH(I, J) < Z(I) And GCH(I, J + 1) > Z(I) Then
W(I) = W(I) + (Z(I) - GCH(I, J)) ^ 2 * (AX(I, J + 1) - AX(I, J)) / (GCH(I, J + 1) - GCH(I, J)) / 2
X(I) = X(I) + (Z(I) - GCH(I, J)) * ((AX(I, J + 1) - AX(I, J)) ^ 2 + (GCH(I, J + 1) - GCH(I, J)) ^ 2) / (GCH(I, J + 1) - GCH(I, J)) ^ (1 / 2)
ElseIf GCH(I, J) > Z(I) And GCH(I, J + 1) < Z(I) Then
W(I) = W(I) + (Z(I) - GCH(I, J + 1)) ^ 2 * (AX(I, J + 1) - AX(I, J)) / (GCH(I, J) - GCH(I, J + 1)) / 2
X(I) = X(I) + (Z(I) - GCH(I, J + 1)) * ((AX(I, J + 1) - AX(I, J)) ^ 2 + (GCH(I, J + 1) - GCH(I, J)) ^ 2) / (GCH(I, J) - GCH(I, J + 1)) ^ (1 / 2)
End If
Next J
End Sub
Public Sub SHUIWEI(Z)
Dim FX As Double 'K值
Dim AAA As Double '面积平均值
Dim RRR As Double '水力半径平均值
Dim CCC As Double '谢才系数平均值
R(I) = W(I) / X(I)
V(I) = Q / W(I)
C(I) = (1 / n(I)) * R(I) ^ (1 / 6)
AAA = (W(I) + W(I - 1)) / 2
RRR = (R(I) + R(I - 1)) / 2
CCC = (C(I) + C(I - 1)) / 2
FX = Z(I - 1) - Z(I) + (1.1 - GG(I)) * (V(I - 1) * V(I - 1) - V(I) * V(I)) / 19.62 + Q * Q * L(I) / (AAA * AAA * CCC * CCC * RRR)
End Sub
两个子程序,现在我的I都要从2开始,每次一运行,第一个的子程序没有问题,可是下面的SHUIWEI(Z)总是显示下标越界。。。。这是怎么回事啊??求大神解决啊!万分感谢,马上就要交毕业设计了