非常感谢你的辛勤耕耘,使我受益蜚浅,你能帮我看看下面的程序那里的问题呢 Sub text() Dim DM As Single '大截面线芯的直径' Dim DN As Single '小截面线芯的直径' Dim M As Integer '大截面线芯的个数' Dim N As Integer '小截面线芯的个数' Dim a As Single '大截面线芯之间的夹角' Dim r As Single '大截面与小截面线芯之间的夹角' Dim b As Single '小截面线芯之间的夹角' Dim D As Single '成缆直径' Dim Dmax As Single Dim Dmin As Single Dim y As Single M = Worksheets("sheet159").Range("u159") N = Worksheets("sheeet159").Range("v159") Pi = 3.1415926 DM = Worksheets("sheeet159").Range("m159") DN = Worksheets("sheet159").Range("p159") Dmax = DM + DM / Sin(Pi / (M + N)) Dmin = DM + DM / Sin(Pi / M) If N = 0 Then D = Dmin End If int1 = 0 Do int1 = int1 + 1 D = (Dmax + Dmin) / 2 a = (1 - 2 * DM ^ 2 / (D - DM) ^ 2) r = (1 - 2 * DM * DN / (D - DM) / (D - DN)) b = (1 - 2 * DN ^ 2 / (D - DN) ^ 2) y = (M - 1) * a + (N - 1) * b + 2 * r If y < 2 * Pi Then Dmax = D Else: Dmin = D End If Loop While y - 2 * Pi < 0.0001 Worksheets("sheeet159").Cells(159, 27) = D
End Sub 红色字体提示出错,然后就是下标越界,请指点,谢谢 |