求VB高手解答该程序的问题

Private Sub Form_click()
l1 = 175
l2 = 700
e = 190
k = ((l2 - l1) ^ 2 - e ^ 2) ^ (1 / 2) / (l2- l1)
S0 = (l2 - l1) * k
t = 3600 / 2000
w1 = 2 * pi / t
λ0 = Atn(e /S0) * 180 / pi
Print "平台印刷机-位移图:"
Open App.Path + "ptysj.txt " ForAppend As #1
Print #1, "平台印刷机-位移图:"
Close #1
Print
For λ = λ0 + 180 To 540 + λ0 Step 10
φ1 = λ * pi /180
b = -l1 * Cos(φ1) * 2
c = e ^ 2 - 2 * e * l1 * Sin(φ1) + (l1) ^ 2- (l2) ^ 2
S = ((-b + (b ^ 2 - 4 * c) ^ (1 / 2)) / 2 -S0) * 2
Print Format(S, "0.00")
Open App.Path + "ptysj.txt " ForAppend As #1
Print #1, Format(S, "0.00")
Close #1
Next λ
Print
Print "平台印刷机-速度图:"
Open App.Path + "ptysj.txt " ForAppend As #1
Print #1, "平台印刷机-速度图:"
Close #1
For λ = λ0 + 180 To 540 + λ0 Step 10
φ1 = λ * pi /180
b = -l1 * Cos(φ1) * 2
c = e ^ 2 - 2 * e * l1 * Sin(φ1) + (l1) ^ 2- (l2) ^ 2
S1 = (-b + (b ^ 2 - 4 * c) ^ (1 / 2)) / 2
cosφ2 = (S1 - l1 * Cos(φ1)) / l2
sinφ2 = (e - l1 * Sin(φ1)) / l2
w2 = (-l1) * w1 * Cos(φ1) / (l2 * cosφ2)
v = -w1 * l1 * Sin(φ1 - φ2) / cosφ2 * 2
Print Format(v, "0.000")
Open App.Path + "ptysj.txt " ForAppend As #1
Print #1, Format(v, "0.000")
Close #1
Next λ
Print
Print "平台印刷机-加速度图:"
Open App.Path + "ptysj.txt " ForAppend As #1
Print #1, "平台印刷机-加速度图:"
Close #1
Print
For λ = λ0 + 180 To 540 + λ0 Step 10
φ1 = λ * pi /180
b = -l1 * Cos(φ1) * 2
c = e ^ 2 - 2 * e * l1 * Sin(φ1) + (l1) ^ 2- (l2) ^ 2
S1 = (-b + (b ^ 2 - 4 * c) ^ (1 / 2)) / 2
cosφ2 = (S1 - l1 * Cos(φ1)) / l2
sinφ2 = (e - l1 * Sin(φ1)) / l2
w2 = (-l1) * w1 * Cos(φ1) / (l2 * cosφ2)
a = (l1 * w1 ^ 2 * Sin(φ1) + l2 * w2 ^ 2 *sinφ2) / (l2 * cosφ2)
A1 = -(l1 * w1 ^ 2 * (Cos(φ1) * cosφ2 +Sin(φ1) * sinφ2) + l2 * w2 ^ 2) / cosφ2 * 2
Print Format(A1, "0.000000")
Open App.Path + "ptysj.txt " ForAppend As #1
Print #1, Format(A1, "0.000")
Close #1
Next λ
End Sub

Open App.Path + "ptysj.txt " ForAppend As #1

上句错误改为:

Open App.Path + "\ptysj.txt " For Append As #1

pi未定义且赋值

Private Const pi As Double = 3.141592654

整个代码如下:

Private Const pi As Double = 3.141592654

Private Sub Form_click()
    l1 = 175
    l2 = 700
    e = 190
    k = ((l2 - l1) ^ 2 - e ^ 2) ^ (1 / 2) / (l2 - l1)
    S0 = (l2 - l1) * k
    t = 3600 / 2000
    w1 = 2 * pi / t
    Î»0 = Atn(e / S0) * 180 / pi
    Print "平台印刷机-位移图:"
    Open App.Path + "\ptysj.txt " For Append As #1
        Print #1, "平台印刷机-位移图:"
    Close #1
    Print
    For Î» = Î»0 + 180 To 540 + Î»0 Step 10
        Ï†1 = Î» * pi / 180
        b = -l1 * Cos(φ1) * 2
        c = e ^ 2 - 2 * e * l1 * Sin(φ1) + (l1) ^ 2 - (l2) ^ 2
        S = ((-b + (b ^ 2 - 4 * c) ^ (1 / 2)) / 2 - S0) * 2
        Print Format(S, "0.00")
        Open App.Path + "\ptysj.txt " For Append As #1
            Print #1, Format(S, "0.00")
        Close #1
    Next Î»
    Print
    Print "平台印刷机-速度图:"
    Open App.Path + "\ptysj.txt " For Append As #1
        Print #1, "平台印刷机-速度图:"
    Close #1
    For Î» = Î»0 + 180 To 540 + Î»0 Step 10
        Ï†1 = Î» * pi / 180
        b = -l1 * Cos(φ1) * 2
        c = e ^ 2 - 2 * e * l1 * Sin(φ1) + (l1) ^ 2 - (l2) ^ 2
        S1 = (-b + (b ^ 2 - 4 * c) ^ (1 / 2)) / 2
        cosφ2 = (S1 - l1 * Cos(φ1)) / l2
        sinφ2 = (e - l1 * Sin(φ1)) / l2
        w2 = (-l1) * w1 * Cos(φ1) / (l2 * cosφ2)
        v = -w1 * l1 * Sin(φ1 - Ï†2) / cosφ2 * 2
        Print Format(v, "0.000")
        Open App.Path + "\ptysj.txt " For Append As #1
            Print #1, Format(v, "0.000")
        Close #1
    Next Î»
    Print
    Print "平台印刷机-加速度图:"
    Open App.Path + "\ptysj.txt " For Append As #1
        Print #1, "平台印刷机-加速度图:"
    Close #1
    Print
    For Î» = Î»0 + 180 To 540 + Î»0 Step 10
        Ï†1 = Î» * pi / 180
        b = -l1 * Cos(φ1) * 2
        c = e ^ 2 - 2 * e * l1 * Sin(φ1) + (l1) ^ 2 - (l2) ^ 2
        S1 = (-b + (b ^ 2 - 4 * c) ^ (1 / 2)) / 2
        cosφ2 = (S1 - l1 * Cos(φ1)) / l2
        sinφ2 = (e - l1 * Sin(φ1)) / l2
        w2 = (-l1) * w1 * Cos(φ1) / (l2 * cosφ2)
        a = (l1 * w1 ^ 2 * Sin(φ1) + l2 * w2 ^ 2 * sinφ2) / (l2 * cosφ2)
        A1 = -(l1 * w1 ^ 2 * (Cos(φ1) * cosφ2 + Sin(φ1) * sinφ2) + l2 * w2 ^ 2) / cosφ2 * 2
        Print Format(A1, "0.000000")
        Open App.Path + "\ptysj.txt " For Append As #1
            Print #1, Format(A1, "0.000")
        Close #1
    Next Î»
End Sub
温馨提示:答案为网友推荐,仅供参考