| 网站首页 | 业界新闻 | 群组 | 人才 | 下载频道 | 博客 | 代码贴 | 编程论坛
共有 1133 人关注过本帖
标题:多重循环,程序卡死
只看楼主 收藏
usstxyy
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2017-6-27
  问题点数:0  回复次数:6   
多重循环,程序卡死
Option Explicit
 Const pi As Single = 3.141592653
 Public wg As Double, wg_ As Double

 


Private Sub Command1_Click()
 Dim i As Long, X As Double, d0 As Double, dt As Double, di As Double, db As Double, s1 As Double, s2 As Double, wmax As Double, yingfengmianji As Double
 Dim sf As Double, st As Double, ff As Double, fb As Double, ft As Double, fi As Double, fm As Double, f0 As Double, leihuaxishu  As Double, liutongmianjibi As Double, fpass As Double
 Dim b1 As Double, b2 As Double, b As Double, rb As Double, r_ As Double, h_ As Double, ha As Double, j As Double, jn As Double, j1 As Double, j2 As Double, j3 As Double
 Dim qva As Double, n As Long, n1 As Long, n2 As Long, cpam As Double, tam As Double, tao_sc As Double, tao_sat As Double, tam1 As Double, tam1shi As Double, tam2 As Double, tamshi As Double, gm As Double, gipass As Double, gpass As Double, qpass As Double, qpass_sat As Double, qpass_sc As Double, qpass_sh As Double
 Dim hpaiqi As Double, tsc As Double, kcu As Double, kau As Double, r0 As Double, r1 As Double, kam As Double, tk As Double, tsh As Double, rs As Double
 Dim hsatv As Double, hsatl As Double, hl As Double, dam1 As Double, dam2 As Double, dam As Double, redb As Double, v_am As Double, ham2 As Double, ham1 As Double, ham As Double, tam2shi As Double, pram As Double
 Dim m As Double, chipianxiaolv As Double, biaomianxiaolv As Double, haj As Double, qianghuaxishu1 As Double, linjieyabi As Double, pcr As Double, pk As Double
 Dim bushu As Long, buchang As Double, ul_sc As Double, prl_sc As Double, rel_sc As Double, rel_satx As Double, f_sc As Double, nul_sc As Double, hi_sc As Double, kl_sc As Double, kl_sat As Double, ul_liq As Double, prl_liq As Double, ul_sh As Double, prl_sh As Double, ul_vap As Double, prl_vap As Double, rel_sh As Double, f_sh As Double, nul_sh As Double, hi_sh As Double, kl_sh As Double, al_sat As Double, hi_sat As Double, hio_sat As Double, hio_sc As Double, hio_sh As Double
 Dim l As Double, lweiyuan As Double, l_weiyuan As Double, kweiyuan As Double, q_weiyuan As Double, dt_sat As Double, dt_sc As Double, dt_sh As Double, l_sc As Double, l_sat As Double, l_sh As Double, l_all_sc As Double, l_all_sat As Double, l_all_sh As Double, l_all As Double, l_danguan As Double
 Dim a_x As Double, s_x As Double, f1 As Double, y As Double, f2 As Double, wef_x As Double, d_sc As Double, zhangli_liq As Double, d_liq As Double, d_vap As Double, d_sh As Double, d_x As Double, m_x As Double, m_sat, m_sc As Double, m_sh As Double
 Dim fgo As Double, flo As Double, f_dp As Double, e_dp As Double, h_dp As Double, fr_dp As Double, we_dp As Double, relo As Double, rego As Double, dtp As Double, dp_sat As Double, dp_all_sat As Double, dpl As Double
 bushu = 500: buchang = 1 / bushu: pcr = 4.99 * 10 ^ 6
 qva = Val(Text13.Text) / 3600: n = Val(Text21.Text): n1 = Val(Text7.Text): n2 = Val(Text4.Text): tam1 = Val(Text12.Text): tam1shi = Val(Text14.Text): gm = Val(Text17.Text)
 tk = Val(Text15.Text): tsh = Val(Text16.Text): tsc = Val(Text24.Text): kcu = Val(Text3.Text): kau = Val(Text23.Text): r0 = Val(Text10.Text): r1 = Val(Text11.Text)
 hpaiqi = guoreqitih(tk, tsh): hsatv = baoheqitih(tk): hsatl = baoheyetih(tk): hl = baoheyetih(tk - tsc): rs = hsatv - hsatl: gpass = gm / n2: qpass_sat = gpass * rs: qpass_sc = gpass * (hsatl - hl): qpass_sh = gpass * (hpaiqi - hsatv): qpass = gpass * (hpaiqi - hl)
 dam1 = shikongqimidu(tam1, tam1shi): tam2 = tam1 + qpass / 1.007 / (dam1 * qva / n2): tam = (tam1 + tam2) / 2: ham1 = genjuwenduqiuh(tam1, tam1shi)
 ham2 = ham1 + qpass / (dam1 * qva / n2): tamshi = genjuhanzhiqiuwendu((ham2 + ham1) / 2): dam = shikongqimidu(tam, tamshi): v_am = kongqiniandu(tam) / dam: kam = kongqidaorexishu(tam): cpam = kongqibirerong(tam): pram = kongqipr(tam)
 '求空气物性参数
 d0 = Val(Text1.Text) / 1000: dt = Val(Text2.Text) / 1000: di = d0 - 2 * dt: s1 = Val(Text8.Text) / 1000: s2 = Val(Text9.Text) / 1000: sf = Val(Text6.Text) / 1000: st = Val(Text5.Text) / 1000: db = d0 + 2 * st
 ff = 2 * (s1 * s2 - pi * db ^ 2 / 4) / sf: fb = pi * db * (sf - st) / sf: ft = ff + fb: fi = pi * di: leihuaxishu = ft / fi: fm = pi * (di + db) / 2: f0 = pi * db: b2 = s1 / 2: rb = db / 2: liutongmianjibi = (sf - st) * (s1 - db) / s1 / sf
 '翅片结构参数计算
 j1 = Val(Text18.Text): j2 = Val(Text19.Text): j3 = Val(Text20.Text)

Do

   wg = 1.5   '假设迎面风速1m/s
  
 wmax = wg / liutongmianjibi: redb = wmax * db / v_am
        
 Option2(0).Caption = j1 * 0.982 * redb ^ 0.424 * (sf / db) ^ -0.0887 * (n * s2 / db) ^ -0.159 * kam / db
 Option2(1).Caption = j1 * 0.687 * redb ^ 0.518 * (sf / db) ^ -0.0935 * (n * s2 / db) ^ -0.199 * kam / db
 Option2(2).Caption = j1 * 0.274 * redb ^ 0.556 * (sf / db) ^ -0.202 * (n * s2 / db) ^ -0.0372 * kam / db
 Option2(3).Caption = j1 * 0.772 * redb ^ 0.477 * (sf / db) ^ -0.363 * (n * s2 / db) ^ -0.217 * kam / db
 j = 0.0014 + 0.2618 * redb ^ -0.4 * (ft / f0) ^ -0.15
 If n >= 4 Then
    jn = j
 Else
      jn = j * 0.992 * (2.24 * redb ^ -0.092 * (n / 4) ^ -0.031) ^ (0.607 * (n - 4))
 End If
 Option2(4).Caption = j1 * jn * dam * wmax * cpam / (pram) ^ (2 / 3) * 1000
 
 For i = 0 To 4 Step 1
        If Option2(i).Value = True Then
            ha = Val(Option2(i).Caption)
        
        End If
  Next i
        If Option1(0).Value = True Then
            b1 = (s1 ^ 2 / 4 + s2 ^ 2) ^ 0.5 / 2: b = 1.27 * b2 / rb * (b1 / b2 - 0.3) ^ 0.5
        Else
            b1 = s1 / 2: b = 1.28 * b2 / rb * (b1 / b2 - 0.2) ^ 0.5
        End If
        
        If Option3(0).Value = True Then
            qianghuaxishu1 = 1
        Else
            qianghuaxishu1 = 1.6
        End If
 r_ = (b - 1) * (1 + 0.35 * Log(b)): m = (2 * ha / (kau * st)) ^ 0.5: chipianxiaolv = (Exp(m * r_ * db / 2) - Exp(-m * r_ * db / 2)) / (Exp(m * r_ * db / 2) + Exp(-m * r_ * db / 2)) / (m * r_ * db / 2)
  biaomianxiaolv = 1 - ff / ft * (1 - chipianxiaolv): haj = ha * biaomianxiaolv
  '空气侧换热计算
  fpass = pi * di ^ 2 / 4: ul_sc = (baoheyetiniandu(tk) + baoheyetiniandu(tk - tsc)) / 2: prl_sc = (baoheyetiprl(tk) + baoheyetiprl(tk - tsc)) / 2: gipass = gpass / (pi * (di / 2) ^ 2): rel_sc = gipass * di / ul_sc: f_sc = (1.58 * Log(rel_sc) - 3.28) ^ -2: kl_sc = (baoheyetidaorexishu(tk) + baoheyetidaorexishu(tk - tsc)) / 2
 nul_sc = (f_sc / 2) * (rel_sc - 1000) * prl_sc / (1.07 + 12.7 * (f_sc / 2) ^ 0.5 * (prl_sc ^ (2 / 3) - 1)): hi_sc = nul_sc * kl_sc / di
  tao_sc = tam1 + qpass_sc / 1.007 / (dam * qva / n2): dt_sc = (tk - tao_sc - (tk - tsc - tam1)) / Log((tk - tao_sc) / (tk - tsc - tam1)): hio_sc = 1 / (leihuaxishu / hi_sc + r0 + r1 + dt * ft / kau / fm + 1 / haj)
  l_sc = 1000 * qpass_sc / hio_sc / dt_sc / ft: l_all_sc = l_sc * n2: d_sc = (baoheyetimidu(tk) + baoheyetimidu(tk - tsc)) / 2: m_sc = l_all_sc * pi * di ^ 2 / 4 * d_sc
  
  
  '过冷区计算
  
  prl_liq = baoheyetiprl(tk): prl_vap = baoheqitiprl(tk): ul_liq = baoheyetiniandu(tk): ul_vap = baoheqitiniandu(tk): d_liq = baoheyetimidu(tk): d_vap = 1 / baoheqitibirong(tk): zhangli_liq = baoheyetizhangli(tk)
 tao_sat = tao_sc + qpass_sat / 1.007 / (dam * qva / n2): dt_sat = (tao_sat - tao_sc) / Log((tk - tao_sc) / (tk - tao_sat)):  kl_sat = baoheyetidaorexishu(tk): pk = baoheyali(tk): linjieyabi = pcr / pk: q_weiyuan = rs * buchang * gpass:

 
  For i = 1 To bushu - 1 Step 1
  X = i * buchang
  rel_satx = (1 - X) * gipass * di / ul_liq: wef_x = ((1 - X) * gipass) ^ 2 * di / d_liq / zhangli_liq
  al_sat = (j2 * qianghuaxishu1 * 0.023 * rel_satx ^ 0.8 * prl_liq ^ 0.4 * kl_sat / di) * (1 + 3.8 * (X / (1 - X)) ^ 0.76 * linjieyabi ^ 0.38): kweiyuan = 1 / (leihuaxishu / al_sat + r0 + r1 + dt * ft / kau / fm + 1 / haj)
     lweiyuan = 0.0002
 Do
    l_weiyuan = 1000 * q_weiyuan / kweiyuan / dt_sat / ft
    lweiyuan = lweiyuan + 0.0001
   Loop While (Abs(-l_weiyuan + lweiyuan - 0.0001) > 0.0001)
 l_sat = l_sat + lweiyuan
 f1 = 1.578 * rel_satx ^ -0.19 * (d_liq / d_vap) ^ 0.22: f2 = 0.0273 * wef_x * rel_satx ^ -0.51 * (d_liq / d_vap) ^ -0.08: y = X * d_liq / (1 - X) / d_vap: s_x = 1 + f1 * (y / (1 + y * f2) - y * f2) ^ 0.5: a_x = 1 / (1 + (1 / X - 1) * s_x * d_vap / d_liq)
 d_x = a_x * d_vap + (1 - a_x) * d_liq
 m_x = d_x * lweiyuan * pi * di ^ 2 / 4
 m_sat = m_sat + m_x
 relo = gipass * di / ul_liq: rego = gipass * di / ul_vap: flo = mochaxishu(relo): fgo = mochaxishu(rego): e_dp = (1 - X) ^ 2 + X ^ 2 * (d_liq * fgo / d_vap / flo): f_dp = X ^ 0.78 * (1 - X) ^ 0.224: h_dp = (d_liq / d_vap) ^ 0.91 * (ul_liq / ul_vap) ^ 0.19 * (1 - ul_vap / ul_liq) ^ 0.7
 dtp = (X / d_vap + (1 - X) / d_liq) ^ -1: fr_dp = gipass ^ 2 / 9.81 / di / dtp ^ 2: we_dp = gipass ^ 2 * di / dtp / zhangli_liq: dpl = flo * lweiyuan * gipass ^ 2 / 2 / di / d_liq: dp_sat = j2 * dpl * (e_dp + 3.24 * f_dp * h_dp / fr_dp ^ 0.045 / we_dp ^ 0.035)
 dp_all_sat = dp_all_sat + dp_sat
 Next i
 l_all_sat = l_sat * n2: hio_sat = 1000 * qpass_sat / (dt_sat * l_sat * ft): hi_sat = leihuaxishu / (1 / hio_sat - (r0 + r1 + dt * ft / kau / fm + 1 / haj))
 '两相区计算
 ul_sh = baoheqitiniandu(tk): prl_sh = baoheqitiprl(tk):  rel_sh = gipass * di / ul_sh: f_sh = (1.58 * Log(rel_sh) - 3.28) ^ -2: kl_sh = baoheqitidaorexishu(tk): d_sh = (1 / baoheqitibirong(tk) + 1 / guoreqitibirong(tk, tk + tsh)) / 2
 nul_sh = (f_sh / 2) * (rel_sh - 1000) * prl_sh / (1.07 + 12.7 * (f_sh / 2) ^ 0.5 * (prl_sh ^ (2 / 3) - 1)): hi_sh = nul_sh * kl_sh / di
   dt_sh = (tk + tsh - tam2 - (tk - tao_sat)) / Log((tk + tsh - tam2) / (tk - tao_sat)): hio_sh = 1 / (leihuaxishu / hi_sh + r0 + r1 + dt * ft / kau / fm + 1 / haj)
  l_sh = 1000 * qpass_sh / hio_sh / dt_sh / ft: l_all_sh = l_sh * n2: m_sh = pi * di ^ 2 / 4 * l_all_sh * d_sh
  '过热区计算
  l_all = l_all_sc + l_all_sat + l_all_sh: l_danguan = l_all / n / n1: yingfengmianji = s1 * n1 * l_danguan:
  wg_ = qva / yingfengmianji
  wg = wg + 0.001
  Loop While (Abs(wg_ - wg + 0.001) > 0.01)
  
  
   Text22.Text = Format(wg_, "0.0000e+00"): Text25.Text = Format(wg, "0.0000e+00"): Text28.Text = Format(n2 * qpass_sc, "0.0000e+00"): Text26.Text = Format(tao_sc, "0.0000e+00"): Text27.Text = Format(hi_sc, "0.0000e+00"): Text30.Text = haj: Text31.Text = Format(hio_sc, "0.0000e+00"): Text32.Text = Format(l_all_sc, "0.0000e+00"): Text33.Text = Format(n2 * l_sc * ft, "0.0000e+00"): Text34.Text = Format(gipass, "0.0000e+00"): Text55.Text = Format(m_sc, "0.0000e+00")
   Text36.Text = Format(n2 * qpass_sat, "0.0000e+00"): Text37.Text = Format(tao_sat, "0.0000e+00"): Text38.Text = Format(hi_sat, "0.0000e+00"): Text35.Text = Format(haj, "0.0000e+00"): Text39.Text = Format(hio_sat, "0.0000e+00"): Text40.Text = Format(l_all_sat, "0.0000e+00"): Text41.Text = Format(l_all_sat * ft, "0.0000e+00"): Text54.Text = Format(m_sat * n2, "0.0000e+00"): Text58.Text = Format(dp_all_sat * 10 ^ -3, "0.0000e+00"):
   Text43.Text = Format(n2 * qpass_sh, "0.0000e+00"): Text45.Text = Format(tam2, "0.0000e+00"): Text44.Text = Format(hi_sh, "0.0000e+00"): Text42.Text = Format(haj, "0.0000e+00"): Text46.Text = Format(hio_sh, "0.0000e+00"): Text47.Text = Format(l_all_sh, "0.0000e+00"): Text48.Text = Format(l_all_sh * ft, "0.0000e+00"): Text56.Text = Format(m_sh, "0.0000e+00")
   Text50.Text = Format(qpass * n2, "0.0000e+00"): Text49.Text = Format(tam2, "0.0000e+00"): Text51.Text = Format(l_all, "0.0000e+00"): Text53.Text = Format(l_all * ft, "0.0000e+00"): Text52.Text = Format(l_danguan, "0.0000e+00"): Text57.Text = Format(1 / guoreqitibirong(tk, tk + tsh), "0.0000e+00"): Text57.Text = Format(m_sat * n2 + m_sc + m_sh, "0.0000e+00")

  
End Sub
 

Function shikongqibaoheshuizhengqiyali(t As Double) As Double
Dim t_k As Double, zhongjian As Double
t_k = t + 273.15
If t < 0.65 Then zhongjian = -5674.35359 / t_k + 6.392547 - 9.67784 * 10 ^ -3 * t_k + 6.22157 * 10 ^ -7 * t_k ^ 2 + 2.0747825 * 10 ^ -9 * t_k ^ 3 - 9.484024 * 10 ^ -13 * t_k ^ 4 + 4.1635019 * Log(t_k) Else zhongjian = -5800.2206 / t_k + 1.3914993 - 4.8640239 * 10 ^ -2 * t_k + 4.1764768 * 10 ^ -5 * t_k ^ 2 - 1.4452093 * 10 ^ -8 * t_k ^ 3 + 6.5459673 * Log(t_k)
shikongqibaoheshuizhengqiyali = Exp(zhongjian)
End Function

Function baohehanshiliang(t As Double) As Double
baohehanshiliang = 0.622 * shikongqibaoheshuizhengqiyali(t) / (101325 - shikongqibaoheshuizhengqiyali(t))
End Function
Function shuizhengqifenyali(tgan As Double, tshi As Double) As Double
shuizhengqifenyali = shikongqibaoheshuizhengqiyali(tshi) - 0.000667 * (tgan - tshi) * 101325
End Function
Function genjuwenduqiud(tgan As Double, tshi As Double) As Double
genjuwenduqiud = 622 * shuizhengqifenyali(tgan, tshi) / (101325 - shuizhengqifenyali(tgan, tshi))
End Function
Function genjuwenduqiuh(tgan As Double, tshi As Double) As Double
genjuwenduqiuh = 1.005 * tgan + (2500 + 1.84 * tgan) * genjuwenduqiud(tgan, tshi) / 1000
End Function
Function shikongqimidu(tgan As Double, tshi As Double) As Double
shikongqimidu = 0.003484 * 101325 / (tgan + 273.15) - 0.00134 * shuizhengqifenyali(tgan, tshi) / (tgan + 273.15)
End Function
Function kongqiniandu(t As Double) As Double
kongqiniandu = 0.000017268 * ((t + 273.15) / 273.15) ^ 0.7
End Function
Function kongqidaorexishu(t As Double) As Double
kongqidaorexishu = 0.024066 * ((t + 273.15) / 273.15) ^ 0.9
End Function
Function kongqibirerong(t As Double) As Double
kongqibirerong = 1.05 - 0.365 * ((t + 273.15) / 1000) + 0.85 * ((t + 273.15) / 1000) ^ 2 - 0.39 * ((t + 273.15) / 1000) ^ 3
End Function
Function kongqipr(t As Double) As Double
kongqipr = 6.5 * 10 ^ -11 * t ^ 4 - 9 * 10 ^ -9 * t ^ 3 + 2 * 10 ^ -6 * t ^ 2 - 0.0003 * t + 0.7091
End Function
Function waibiaomianji(doe As Double, bfe As Double, s1 As Double, s2 As Double, sfe As Double) As Double
Dim dbe As Double, ffe As Double, fbe As Double
dbe = doe + 2 * bfe
ffe = 2 * (s1 * s2 - 0.25 * 3.14 * dbe ^ 2) / sfe
fbe = 3.14 * dbe * (sfe - bfe) / sfe
waibiaomianji = ffe
End Function
Function guansuwaibiaomianji(doe As Double, bfe As Double, sfe As Double) As Double
Dim dbe As Double, ffe As Double, fbe As Double
dbe = doe + 2 * bfe
guansuwaibiaomianji = 3.14 * dbe * (sfe - bfe) / sfe
End Function
Function baoheyali(tsat As Double) As Double
Dim a1 As Double, a2 As Double, a3 As Double
a1 = 21.25957: a2 = -2028.521: a3 = 249.1811
baoheyali = Exp(a1 + a2 / (tsat + a3))

End Function
Function baohewendu(psat As Double) As Double
Dim a1 As Double, a2 As Double, a3 As Double
a1 = 21.25957: a2 = -2028.521: a3 = 249.1811
baohewendu = a2 / (Log(psat) - a1) - a3

End Function
Function baoheyetih(tsat As Double) As Double
Dim a4 As Double, a5 As Double, a6 As Double, a7 As Double
a4 = 200001.3: a5 = 1169.74: a6 = 1.50199: a7 = 9.3947 * 10 ^ -3
baoheyetih = (a4 + a5 * tsat + a6 * tsat ^ 2 + a7 * tsat ^ 3) / 1000
End Function
Function baoheqitih(tsat As Double) As Double
Dim a8 As Double, a9 As Double, a10 As Double, a11 As Double, a12 As Double
a8 = 250261: a9 = 373.114: a10 = -1.923703: a11 = -13.772 * 10 ^ -3: a12 = 154887
baoheqitih = (a8 + a9 * tsat + a10 * tsat ^ 2 + a11 * tsat ^ 3 + a12) / 1000
End Function
Function guoreqitih(tsat As Double, tsh As Double) As Double
Dim a13 As Double, a14 As Double, a15 As Double, a16 As Double, a17 As Double, a18 As Double, a12 As Double
a12 = 154887: a13 = 2.82622 * 10 ^ -3: a14 = 7.78762 * 10 ^ -7: a15 = 12.67187 * 10 ^ -6: a16 = -6.98963 * 10 ^ -8: a17 = 19.53359 * 10 ^ -8: a18 = -12.7248 * 10 ^ -10
guoreqitih = (1 + a13 * tsh + a14 * tsh ^ 2 + a15 * tsh * tsat + a16 * tsh ^ 2 * tsat + a17 * tsh * tsat ^ 2 + a18 * tsh ^ 2 * tsat ^ 2) * (baoheqitih(tsat) * 1000 - a12) / 1000 + a12 / 1000
End Function
Function baoheqitibirong(tsat As Double) As Double
Dim a19 As Double, a20 As Double, a21 As Double, a22 As Double, a23 As Double, a24 As Double
a19 = -11.99684: a20 = 2348.671: a21 = 1.409043: a22 = -0.13675 * 10 ^ -4: a23 = -18.16509 * 10 ^ -6: a24 = -3.77724 * 10 ^ -7
baoheqitibirong = Exp(a19 + a20 / (tsat + 273.15)) * (a21 + a22 * tsat + a23 * tsat ^ 2 + a24 * tsat ^ 3)
End Function
Function guoreqitibirong(tsat As Double, tsh As Double) As Double
Dim a25 As Double, a26 As Double, a27 As Double, a28 As Double, a29 As Double, a30 As Double
a25 = 4.889336 * 10 ^ -3: a26 = -2.47357 * 10 ^ -6: a27 = 2.95154 * 10 ^ -5: a28 = -1.64781 * 10 ^ -7: a29 = 9.105029 * 10 ^ -7: a30 = -5.389134 * 10 ^ -9
guoreqitibirong = (1 + a25 * tsh + a26 * tsh ^ 2 + a27 * tsh * tsat + a28 * tsh ^ 2 * tsat + a29 * tsh * tsat ^ 2 + a30 * tsh ^ 2 * tsat ^ 2) * baoheqitibirong(tsat)
End Function
Function baoheyetimidu(tsat As Double) As Double
Dim a31 As Double, a32 As Double, a33 As Double, a34 As Double, a35 As Double, tc As Double
baoheyetimidu = -1.3 * 10 ^ -4 * tsat ^ 3 - 6 * 10 ^ -3 * tsat ^ 2 - 3.3774 * tsat + 1281.2
End Function
Function baoheyetiniandu(tsat As Double) As Double
baoheyetiniandu = Exp(-1.5326 - 0.0109 * tsat + 5 * 10 ^ -6 * tsat ^ 2 - 2 * 10 ^ -7 * tsat ^ 3 + 7 * 10 ^ -10 * tsat ^ 4 - 2 * 10 ^ -11 * tsat ^ 5) / 1000
End Function
Function baoheqitiniandu(tsat As Double) As Double
 baoheqitiniandu = Exp(-4.4774 + 0.0037 * tsat + 5 * 10 ^ -7 * tsat ^ 2 + 1 * 10 ^ -7 * tsat ^ 3 + 9 * 10 ^ -10 * tsat ^ 4 - 6 * 10 ^ -12 * tsat ^ 5 + 2 * 10 ^ -13 * tsat ^ 6) / 1000
End Function
Function baoheyetidaorexishu(tsat As Double) As Double
baoheyetidaorexishu = 0.0942 - 0.00045 * tsat
End Function
Function baoheqitidaorexishu(tsat As Double) As Double
baoheqitidaorexishu = 0.0094 + 7 * 10 ^ -5 * tsat + 3 * 10 ^ -7 * tsat ^ 2 + 2 * 10 ^ -9 * tsat ^ 3 + 7.35 * 10 ^ -11 * tsat ^ 4
End Function
Function baoheyetiprl(tsat As Double) As Double
baoheyetiprl = 2.665 - 0.0101 * tsat + 0.0001 * tsat ^ 2 - 5 * 10 ^ -7 * tsat ^ 3 + 1.35 * 10 ^ -8 * tsat ^ 4
End Function
Function baoheqitiprl(tsat As Double) As Double
baoheqitiprl = 0.8928 + 0.0021 * tsat + 2 * 10 ^ -5 * tsat ^ 2 + 1 * 10 ^ -7 * tsat ^ 3 + 7.2 * 10 ^ -9 * tsat ^ 4
End Function
Function baoheyetizhangli(tsat As Double) As Double
baoheyetizhangli = 8.27 * 10 ^ -10 * tsat ^ 3 + 1.2 * 10 ^ -9 * tsat ^ 2 - 0.000141 * tsat + 0.0117
End Function
Function mochaxishu(rel As Double) As Double
If rel < 2300 Then
mochaxishu = 64 / rel
Else
mochaxishu = 0.316 * rel ^ -0.25
End If
End Function
Function genjuhanzhiqiuwendu(hkongqiw As Double) As Double
Dim hkongqiw_  As Double
genjuhanzhiqiuwendu = 0.1
Do
  hkongqiw_ = genjuwenduqiuh(genjuhanzhiqiuwendu, genjuhanzhiqiuwendu)
  genjuhanzhiqiuwendu = genjuhanzhiqiuwendu + 0.001
  Loop While ((hkongqiw - hkongqiw_) > 0.0001)
End Function





2017-06-27 15:33
风吹过b
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:206
帖 子:4185
专家分:25726
注 册:2008-10-15
  得分:0 
变量和函数太多了,变量名和函数你可以用中文来命名吗?

你卡死在哪个循环里?
IDE环境,卡死时,按 CTRL+BLRAK,看一下执行在哪一行,属于哪个循环,
然后这个循环时的各个变量值是多少,符不符合预期,如果不符合,哪个变量出了问题,对应查找代码。

授人于鱼,不如授人于渔
早已停用QQ了
2017-06-27 15:44
xiangyue0510
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:85
帖 子:908
专家分:5207
注 册:2015-8-10
  得分:0 
那代码是嵌套循环,就发那些代码就好。一股脑什么都发上来,真没有兴趣和耐心去看。
2017-06-28 21:20
lhj56459897
Rank: 2
等 级:论坛游民
帖 子:17
专家分:47
注 册:2017-7-8
  得分:0 
提个小小的建议,你这个太多的,一般人没时间这么去看,你自己可以先用两三个小数据去编,如果可以了,再增加其它的,这样检查起来也容易些。
2017-07-08 11:30
liyanq
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2018-2-4
  得分:0 
在多重循环中添加DoEvents
2018-02-04 21:01
suzhanpeng
Rank: 3Rank: 3
等 级:论坛游侠
威 望:4
帖 子:45
专家分:168
注 册:2016-9-28
  得分:0 
大概看了一下,好像没有多级镶套循环,都是单循环,只是计算量大,每次循环都要重新计算一次,这应该是造成卡死的原因。

[此贴子已经被作者于2018-2-5 10:56编辑过]

2018-02-05 10:55
ZHRXJR
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:59
帖 子:667
专家分:3637
注 册:2016-5-10
  得分:0 
程序代码:
Private Sub Command1_Click()
'........................................................
Do      '第一层DO循环
'
..............................................
    Do       '第二层DO循环
'
............................................
    Loop While (Abs(-l_weiyuan + lweiyuan - 0.0001) > 0.0001)   '如果第二层DO循环条件始终成立,将进入死循环
'
...................................................
Loop While (Abs(wg_ - wg + 0.001) > 0.01)   '如果第一层DO循环条件始终成立,将进入死循环
End Sub

因此循环条件是退出循环的关键,检查你的循环条件
程序代码:
Function genjuhanzhiqiuwendu(hkongqiw As Double) As Double
Dim hkongqiw_  As Double
genjuhanzhiqiuwendu = 0.1
Do
  hkongqiw_ = genjuwenduqiuh(genjuhanzhiqiuwendu, genjuhanzhiqiuwendu)
  genjuhanzhiqiuwendu = genjuhanzhiqiuwendu + 0.001
  Loop While ((hkongqiw - hkongqiw_) > 0.0001)   '这个函数中的DO循环也存在上面的问题
End Function

QQ    2653043392
2018-02-06 10:16







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.223083 second(s), 8 queries.
Copyright©2004-2018, BCCN.NET, All Rights Reserved