| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1744 人关注过本帖
标题:实时错误“6”溢出,这是怎么回事哈,我是个菜鸟哈,求帮助
只看楼主 加入收藏
石头621627
Rank: 2
等 级:论坛游民
帖 子:4
专家分:10
注 册:2013-2-19
结帖率:0
收藏
已结贴  问题点数:5 回复次数:5 
实时错误“6”溢出,这是怎么回事哈,我是个菜鸟哈,求帮助
图片附件: 游客没有浏览图片的权限,请 登录注册
图片附件: 游客没有浏览图片的权限,请 登录注册

Const T0 As Single = 273.15
Const R As Single = 8.314
Const P0 As Single = 0
Dim p As Single, T As Single, Q1 As Single, T1 As Single, Q2 As Single, T2 As Single, T3 As Single, T4 As Single
Dim Y(6) As Single, f(6) As Single
Dim A1(1, 6) As Single, B1(1, 6) As Single, C1(1, 6) As Single, D1(1, 6) As Single, E1 As Single, f1 As Single, G1 As Single, H1 As Single
Dim A2(1, 6) As Single, B2(1, 6) As Single, C2(1, 6) As Single, D2(1, 6) As Single, E2 As Single, F2 As Single, G2 As Single, H2 As Single
Dim V(1, 1) As Single

Function Tem(p) As Single
     Dim a As Single
     a = 6.38 * Log(9.869 * p) + 262
     Tem = a
End Function

Function M1(T1) As Single
    Dim w As Single, i As Integer, j As Integer, C11 As Single, C22 As Single
     For i = 0 To 1 Step 1
        For j = 0 To 6 Step 1
           C1(i, j) = A1(i, j) / T1 * Exp(B1(i, j) / T1 + D1(i, j) / (T1 * T1))
        Next j
     Next i
     C11 = 0: C22 = 0
     For i = 0 To 6 Step 1
        C11 = C11 + C1(0, i) * Y(i) * p
        C22 = C22 + C1(1, i) * Y(i) * p
     Next i
    C11 = V(0, 0) * Log(C11 + 1) + V(0, 1) * Log(C22 + 1)
    w = E1 / (R * T0) - (f1 * T0 - G1 - Q1 * T0 * T0 / 2) / R * (1 / T1 - 1 / T0) - (f1 - Q1 * T0) / R * Log(T1 / T0) - Q1 / (2 * R) * (T1 - T0) + H1 * (p - P0) / (R * T1) - C11
    M1 = w
End Function

Function M2(T1) As Single
     Dim w1 As Single, k As Integer, n As Integer, C3 As Single, C4 As Single, C5 As Single, C6 As Single
     For k = 0 To 1 Step 1
        For n = 0 To 6 Step 1
           C1(k, n) = A1(k, n) / T1 * Exp(B1(k, n) / T1 + D1(k, n) / (T1 * T1))
        Next n
     Next k
     C3 = 0: C4 = 0: C5 = 0: C6 = 0
     For n = 0 To 6 Step 1
        C3 = C3 + C1(0, n) * Y(n) * p
        C4 = C4 + C1(1, n) * Y(n) * p
        C5 = C5 - (C1(0, n) / T1 + (B1(0, n) / (T1 * T1) + 2 * D1(0, n) / (T1 * T1 * T1)) * C1(0, n)) * Y(n) * p
        C6 = C6 - (C1(1, n) / T1 + (B1(1, n) / (T1 * T1) + 2 * D1(1, n) / (T1 * T1 * T1)) * C1(1, n)) * Y(n) * p
     Next n
     C5 = V(0, 0) * C5 / (1 + C3) + V(0, 1) * C6 / (1 + C4)
     w1 = (f1 * T0 - G1 - Q1 * T0 * T0 / 2) / R / T1 / T1 - (f1 - Q1 * T0) / R / T1 - Q1 * T1 / R / 2 - C5
     M2 = w1
End Function

Function M3(T1) As Single
     Dim w As Single, i As Integer, j As Integer, C1 As Single, C2 As Single
     For i = 0 To 1 Step 1
        For j = 0 To 6 Step 1
           C2(i, j) = A2(i, j) / T1 * Exp(B2(i, j) / T1 + D2(i, j) / (T1 * T1))
        Next j
     Next i
     C1 = 0: C2 = 0
     For i = 0 To 6 Step 1
        C1 = C1 + C2(0, i) * Y(i) * p
        C2 = C2 + C2(1, i) * Y(i) * p
     Next i
     C1 = V(1, 0) * Log(C1 + 1) + V(1, 1) * Log(C2 + 1)
   w = E2 / (R * T0) - (F2 * T0 - G2 - Q2 * T0 * T0 / 2) / R * (1 / T1 - 1 / T0) - (F2 - Q2 * T0) / R * Log(T1 / T0) - Q2 / (2 * R) * (T1 - T0) + H2 * (p - P0) / (R * T1) - C1
     M3 = w
End Function


Function M4(T1) As Single
     Dim w1 As Single, k As Integer, n As Integer, C3 As Single, C4 As Single, C5 As Single, C6 As Single
     For k = 0 To 1 Step 1
        For n = 0 To 6 Step 1
           C2(k, n) = A2(k, n) / T1 * Exp(B2(k, n) / T1 + D2(k, n) / (T1 * T1))
        Next n
     Next k
     C3 = 0: C4 = 0: C5 = 0: C6 = 0
     For n = 0 To 6 Step 1
        C3 = C3 + C2(0, n) * Y(n) * p
        C4 = C4 + C2(1, n) * Y(n) * p
        C5 = C5 - (C2(0, n) / T1 + (B2(0, n) / (T1 * T1) + 2 * D2(0, n) / (T1 * T1 * T1)) * C2(0, n)) * Y(n) * p
        C6 = C6 - (C2(1, n) / T1 + (B2(1, n) / (T1 * T1) + 2 * D2(1, n) / (T1 * T1 * T1)) * C2(1, n)) * Y(n) * p
     Next n
     C5 = V(1, 0) * C5 / (1 + C3) + V(1, 1) * C6 / (1 + C4)
     w1 = (F2 * T0 - G2 - Q2 * T0 * T0 / 2) / R / T1 / T1 - (F2 - Q2 * T0) / R / T1 - Q2 * T1 / R / 2 - C5
     M4 = w1
End Function

Private Sub Command2_Click()
Y(0) = Val(CH4input.Text): Y(1) = Val(C2H6input.Text): Y(2) = Val(C3H8input.Text)
Y(3) = Val(C4H10input.Text): Y(4) = Val(N2input.Text): Y(5) = Val(CO2input.Text)
Y(6) = Val(H2Sinput.Text)

A1(0, 0) = 48.67: B1(0, 0) = 0.00249527: D1(0, 0) = 0.00000004435: A1(1, 0) = 174.46: B1(1, 0) = 0.00249568: D1(1, 0) = 0.00000003298
A1(0, 1) = 0#: B1(0, 1) = 0#: D1(0, 1) = 0#: A1(1, 1) = 6.82: B1(1, 1) = 0.00397303: D1(1, 1) = 0.0000000465
A1(0, 2) = 0#: B1(0, 2) = 0#: D1(0, 2) = 0#: A1(1, 2) = 0.69: B1(1, 2) = 0.00375345: D1(1, 2) = 0.00000005197
A1(0, 3) = 0#: B1(0, 3) = 0#: D1(0, 3) = 0#: A1(1, 3) = 0#: B1(1, 3) = 0#: D1(1, 3) = 0#
A1(0, 4) = 63.79: B1(0, 4) = 0.00223917: D1(0, 4) = 0.00000003749: A1(1, 4) = 219.76: B1(1, 4) = 0.00201908: D1(1, 4) = 0.00000002648
A1(0, 5) = 0.0753: B1(0, 5) = 0.00418948: D1(0, 5) = 0.00000004384: A1(1, 5) = 7.62: B1(1, 5) = 0.0036632: D1(1, 5) = 0.00000002901
A1(0, 6) = 18.9: B1(0, 6) = 0.0041595: D1(0, 6) = 0.00000004613: A1(1, 6) = 286.12: B1(1, 6) = 0.00387112: D1(1, 6) = 0.00000003408

A2(0, 0) = 47.05: B2(0, 0) = 0.00247385: D2(0, 0) = 0.00000004414: A2(1, 0) = 904.59: B2(1, 0) = 0.00222312: D2(1, 0) = 0.0000000156
A2(0, 1) = 0#: B2(0, 1) = 0#: D2(0, 1) = 0#: A2(1, 1) = 108.08: B2(1, 1) = 0.00399167: D2(1, 1) = 0.00000002398
A2(0, 2) = 0#: B2(0, 2) = 0#: D2(0, 2) = 0#: A2(1, 2) = 1.81: B2(1, 2) = 0.00551284: D2(1, 2) = 0.00000003498
A2(0, 3) = 0#: B2(0, 3) = 0#: D2(0, 3) = 0#: A2(1, 3) = 0.00955: B2(1, 3) = 0.007019175: D2(1, 3) = 0.0000000469
A2(0, 4) = 63.3: B2(0, 4) = 0.00221913: D2(0, 4) = 0.00000003879: A2(1, 4) = 1200.93: B2(1, 4) = 0.00174363: D2(1, 4) = 0.00000001259
A2(0, 5) = 0.07: B2(0, 5) = 0.00418047: D2(0, 5) = 0.00000004341: A2(1, 5) = 0.76: B2(1, 5) = 0.0028971: D2(1, 5) = 0.00000001511
A2(0, 6) = 1.82: B2(0, 6) = 0.004136: D2(0, 6) = 0.00000004594: A2(1, 6) = 273.72: B2(1, 6) = 0.00320724: D2(1, 6) = 0.0000000157

E1 = 1120: E2 = 931

V(0, 0) = 0.04348: V(0, 1) = 0.13043
V(1, 0) = 0.11765: V(1, 1) = 0.05882
p = Val(Pinput.Text)
T1 = Tem(p)
If T1 > T0 Then
  G1 = -4207: G2 = -4611: H1 = 4.5959: H2 = 4.99644
  f1 = -34.583: F2 = -36.8607: Q1 = 0.189: Q2 = 0.1809
Else
  G1 = 1714: G2 = 1400: H1 = 2.9959: H2 = 3.39644
  f1 = 3.315: F2 = 1.029: Q1 = 0.0121: Q2 = 0.00377
End If
Do While Abs(T1 - T2) > 0.001
   T2 = T1 - M1(T1) / M2(T1)
Loop
T3 = T2
Do While Abs(T1 - T2) > 0.001
   T2 = T1 - M3(T1) / M4(T1)
Loop
T4 = T2
If T3 > T4 Then
  T = T3
  TYPE1output.Text = Str$(1)
Else
  T = T4
  TYPE1output.Text = Str$(2)
End If
Toutput.Text = Str$(T)

End Sub

Private Sub Form_Load()
M1 (T1)
End Sub

[ 本帖最后由 石头621627 于 2013-2-19 14:24 编辑 ]
2013-02-19 11:43
曾大虾
Rank: 2
等 级:论坛游民
威 望:2
帖 子:17
专家分:62
注 册:2007-8-17
收藏
得分:3 
这几个数组A1(), B1(), C1(), D1(), Y(), V()没有定义和指定上下标,造成的
问题不清晰,请发完整源码,以便给你解决问题

[ 本帖最后由 曾大虾 于 2013-2-19 13:09 编辑 ]
2013-02-19 13:07
石头621627
Rank: 2
等 级:论坛游民
帖 子:4
专家分:10
注 册:2013-2-19
收藏
得分:0 
回复 2楼 曾大虾
谢谢大神了,已经重新发了,可以指点指点么
2013-02-19 14:25
曾大虾
Rank: 2
等 级:论坛游民
威 望:2
帖 子:17
专家分:62
注 册:2007-8-17
收藏
得分:0 
Private Sub Form_Load()
M1 (T1)
End Sub
是什么意思?
我的qq:55719889
T1未赋值,就使用,造成数组无上下限,肯定要“溢出”,你赋个值不就不会溢出了!

[ 本帖最后由 曾大虾 于 2013-2-19 15:26 编辑 ]
2013-02-19 15:16
石头621627
Rank: 2
等 级:论坛游民
帖 子:4
专家分:10
注 册:2013-2-19
收藏
得分:0 
回复 4楼 曾大虾
不好意思哈,这一段似乎是多余的,不知道怎么冒出来的
2013-02-19 16:14
Artless
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:4211
专家分:28888
注 册:2009-4-8
收藏
得分:3 
以下是引用石头621627在2013-2-19 16:14:48的发言:

不好意思哈,这一段似乎是多余的,不知道怎么冒出来的

删除

无知
2013-02-20 14:33
快速回复:实时错误“6”溢出,这是怎么回事哈,我是个菜鸟哈,求帮助
数据加载中...
 
   



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

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