Option ExplicitDim L1 As Single, L2 As Single, t As Single, d!, k!, kd!, thkd!, H!, D1!Dim CD As Single, CM As Single, l As Single, Ko As SingleDim Fhdmax As Single, Fhlmax As Single, Mhdmax As Single, Mhlmax!, Fhmax!, Mhmax!Dim θ As Si ngleConst Pi = 3.141592653Const G = 9.8Const γ = 1025Private Sub Command1_Click()Dim r As IntegerDo While TrueL1 = Val(InputBox("请输入波长L1:", "求解设计波长:", "100"))t = Val(InputBox("请输入设计波周期T:", "请输入", "6"))d = Val(InputBox("请输入设计水深d:", "请输入", "20"))If L1 <= 0 Thenr = MsgBox("请输入一个正数!", 5, "输入错误")If r = 2 ThenEndEnd IfElseExit DoEnd IfLoopk = 2 * Pi / L1kd = k * dthkd = (Exp(kd) - Exp(-kd)) / (Exp(kd) + Exp(-kd))L2 = G * (t ^ 2) * thkd / (2 * Pi)Do Until Abs(L2 - L1) < 0.001L1 = L2k = 2 * Pi / L1kd = k * dthkd = (Exp(kd) - Exp(-kd)) / (Exp(kd) + Exp(-kd))L2 = G * (t ^ 2) * thkd / (2 * Pi)LoopPrint "设计波长是:"; L2Print "波数:"; Format$(k, "0.0000")End SubPrivate Sub Command2_Click()EndEnd SubPrivate Sub Command3_Click()H = Val(InputBox("请输入设计波高H:", "请输入", "3"))D1 = Val(InputBox("请输入桩柱直径D1:", "请输入", "2"))l = Val(InputBox("请输入桩柱间距l:", "请输入", "15"))If d / L2 < 0.5 ThenPrintPrint "相对水深d/L2:"; d / L2Print "采用线性波理论计算:"ElseMsgBox "重新选择计算理论"End IfPrint "波陡:"; H / L2Print "相对柱径:"; D1 / L2If D1 / L2 < 0.2 ThenPrint "属于小直径桩柱"ElsePrint "属于大直径桩柱"End IfCD = Val(InputBox("请输入拖曳力系数:", "请输入", "1.0"))CM = Val(InputBox("请输入质量系数:", "请输入", "2.0")) PrintPrint "选用拖曳力系数:"; CDPrint "选用质量系数:"; CMDim LD As SingleLD = l / D1Print "桩柱相对间距:"; LDPrint "群桩系数Ko:";If LD > 4 ThenKo = 1Print KoElseIf LD < 4 And LD > 3 ThenKo = 1.25Print KoElseIf LD < 2 ThenKo = 1.5Print KoEnd IfEnd SubPrivate Sub Command4_Click()Dim K1 As Single, K2 As Single, K3 As Single, K4 As SingleDim e As Single, θo As SingleK1 = (2 * k * (d + H / 2) + sh(2 * k * (d + H / 2))) / (8 * sh(2 * k * d)) Fhdmax = CD * γ * G * D1 * (H ^ 2) * K1 / 2PrintPrint "K1值:"; Format$(K1, "0.0000")Print "单桩柱最大水平拖曳力Fhdmax:"; FhdmaxK2 = th(k * d)Fhlmax = CM * γ * G * Pi * (D1 ^ 2) * H * K2 / 8PrintPrint "K2值:"; Format$(K2, "0.0000")Print "单桩柱最大水平惯性力Fhlmax:"; FhlmaxK3 = (2 * (k ^ 2) * (d + H / 2) ^ 2 + 2 * k * (d + H / 2) * sh(2 * k * (d + H / 2)) - ch(2 * k * (d + H / 2)) + 1) / (32 * sh(2 * k * d))Mhdmax = CD * γ * G * D1 * (H ^ 2) * L2 * K3 / (2 * Pi)PrintPrint "K3值:"; Format$(K3, "0.0000")Print "单桩柱最大水平拖曳力矩Mhdmax:"; MhdmaxK4 = (k * d * sh(k * d) - ch(k * d) + 1) / ch(k * d)Mhlmax = CM * γ * G * (D1 ^ 2) * H * L2 * K4 / 16PrintPrint "K4值:"; Format$(K4, "0.0000")Print "单桩柱最大水平惯性力矩Mhlmax:"; MhlmaxIf Fhlmax >= 2 * Fhdmax ThenFhmax = Fhlmaxθo = 90ElseIf Fhlmax < 2 * Fhdmax ThenFhmax = Fhdmax * ((1 + (Fhlmax / Fhdmax) ^ 2) / 4)θo = arcsin(Fhlmax / (2 * Fhdmax))End IfPrintPrint "单桩柱最大水平波力Fhmax:"; FhmaxIf Mhlmax >= 2 * Mhdmax ThenMhmax = MhlmaxElseIf Mhlmax < 2 * Mhdmax ThenMhmax = Mhdmax * ((1 + (Mhlmax / Mhdmax) ^ 2) / 4)End IfPrintPrint "单桩柱最大水平波力矩Mhmax:"; MhmaxPrint "最大水平波力和最大水平波力矩的相位θo:"; θoe = Mhmax / FhmaxPrintPrint "最大水平波力作用点离海底的距离e:"; eEnd SubPublic Function sh(n) As Singlesh = (Exp(n) - Exp(-n)) / 2End FunctionPublic Function ch(n) As Singlech = (Exp(n) + Exp(-n)) / 2End FunctionPublic Function th(n) As Singleth = (Exp(n) - Exp(-n)) / (Exp(n) + Exp(-n))End FunctionPublic Function arcsin(n) As Singlearcsin = Atn(n / Sqr(-n * n + 1))End FunctionPublic Function FH(θ) As SingleFH = Fhdmax * Cos(θ) * Abs(Cos(θ)) + Fhlmax *Sin(θ)End FunctionPublic Function MH(θ) As SingleMH = Mhdmax * Cos(θ) * Abs(Cos(θ)) + Mhlmax * Sin(θ)End FunctionPrivate Sub Command5_Click()Dim i As IntegerOpen "C:\Documents and Settings\All Users\桌面\不同相位水平波力.txt" For Output As #1 Print #1, Tab(8); "相位角θ"; Spc(3); "cosθ"; Spc(3); "cosθ|cosθ|"; Spc(3); "sinθ"; Spc(3); "Fhdmaxcosθ|cosθ|"; Spc(3); "Fhlmaxsinθ"; Spc(6); "FH"For i = 0 To 180 Step 15θ = i * Pi / 180Print #1, Tab(10); i; Tab(20); Format$(Cos(θ), "0.0000");Print #1, Tab(30); Format$(Cos(θ) * Abs(Cos(θ)), "0.0000");Print #1, Tab(40); Format$(Sin(θ), "0.0000");Print #1, Tab(55); Format(Fhdmax * Cos(θ) * Abs(Cos(θ)), "0.00");Print #1, Tab(70); Format(Fhlmax * Sin(θ), "0.00");Print #1, Tab(85); Format(FH(θ), "0.00")Next iClose #1End SubPrivate Sub Command6_Click()Dim i As IntegerOpen "C:\Documents and Settings\All Users\桌面\不同相位水平波力矩.txt" For Output As #2Print #2, Tab(8); "相位角θ"; Spc(3); "cosθ"; Spc(3); "cosθ|cosθ|"; Spc(3); "sinθ"; Spc(3); "Fhdmaxcosθ|cosθ|"; Spc(3); "Mhlmaxsinθ"; Spc(6); "MH"For i = 0 To 180 Step 15θ = i * Pi / 180Print #2, Tab(10); i; Tab(20); Format$(Cos(θ), "0.0000");Print #2, Tab(30); Format$(Cos(θ) * Abs(Cos(θ)), "0.0000");Print #2, Tab(40); Format$(Sin(θ), "0.0000");Print #2, Tab(55); Format(Mhdmax * Cos(θ) * Abs(Cos(θ)), "0.00");Print #2, Tab(70); Format(Mhlmax * Sin(θ), "0.00");Print #2, Tab(85); Format(MH(θ), "0.00")Next iClose #2End SubPrivate Sub Command7_Click()Dim ψ As SingleDim ∑H As SingleDim i As IntegerDim t As Single, m As Integerψ = l * 360 / L2PrintPrint "前后两桩柱的波浪位相差ψ:"; ψt = 0For i = 0 To 180 - ψ∑H = FH(i) + FH(i + ψ)If t < ∑H Thent = ∑Hm = iEnd IfNext iPrint "发生最大水平合波力的相位:"; m Print "前后两桩柱的最大水平合波力为:"; t End SubPrivate Sub Command8_Click()ClsEnd SubPrivate Sub Command9_Click()Dim ψ As Sing leDim ∑M As SingleDim i As IntegerDim t As Single, m As Integerψ = l * 360 / L2t = 0For i = 0 To 180 - ψ∑M = MH(i) + MH(i + ψ)If t < ∑M Thent = ∑Mm = iEnd IfNext iPrintPrint "发生最大水平合波力矩的相位:"; m Print "前后两桩柱的最大水平合波力矩为:"; t End Sub海洋环境作业计算结果:。