?? frmhybridgas.frm
字號:
'**********************以下為計算**********************************
For I = 1 To 6 '體積百分含量賦值
c_vol(I) = Val(Text2(I - 1).Text)
Next I
For I = 1 To 6
Wm_m = Wm_m + c_vol(I) * Val(Text3(I - 1).Text) * 0.01
Next I
If Wm_m = 0 Then
MsgBox "請輸入含量", vbCritical, "錯誤"
Exit Sub
Else
R_m = 8315.488 / Wm_m
End If
For I = 1 To 6
emi(I) = c_vol(I) * Val(Text3(I - 1).Text) * 0.01 / Wm_m
Next I
For I = 1 To 6
Cp = Cp + emi(I) * Cp1(I)
Next I
k = Cp * 1000 / (Cp * 1000 - R_m)
dens = p / (R_m * T) ' 按照理想氣體計算空氣的密度
RdRw = 18.016 / Wm_m
If Option1.Value = True Then '輸入條件判斷
ElseIf Option3.Value = True And Option4.Value = False Then
hum_r = Val(Text4.Text)
If p - ps * hum_r * 0.01 < 100 Then
MsgBox "氣體接近液化,請重新輸入氣體溫度,濕度和壓力", vbCritical, "警告"
Else
hum_a = RdRw * hum_r * 0.01 * ps / (p - ps * hum_r * 0.01) '計算絕對濕度
End If
Rm_h = (R_m + hum_a * 0.4616) / (1 + 0.001 * hum_a) '混合氣體和水蒸氣混合后的氣體常數
Sk = Cp * 1000 / (Cp * 1000 - Rm_h) '混合氣體和水蒸氣混合后的絕熱指數
dens = p / (Rm_h * T)
R_m = Rm_h
k = Sk
ElseIf Option3.Value = False And Option4.Value = True Then
hum_a = Val(Text5.Text) * 0.001
hum_r = hum_a * 100 * p / ((hum_a + RdRw) * ps)
If p - ps * hum_r * 0.01 < 100 Then
MsgBox "氣體接近液化,請重新輸入氣體溫度,濕度和壓力", vbCritical, "警告"
End If
Text4.Text = hum_r
Rm_h = (R_m + hum_a * 0.4616) / (1 + 0.001 * hum_a) '混合氣體和水蒸氣混合后的氣體常數
Sk = Cp * 1000 / (Cp * 1000 - Rm_h) '混合氣體和水蒸氣混合后的絕熱指數
dens = p / (Rm_h * T)
R_m = Rm_h
k = Sk
End If '文本框輸出最后結果
Text4.Text = hum_r
Text5.Text = hum_a * 1000
Text6(0).Text = k
Text6(1).Text = Cp * 1000
Text6(2).Text = R_m '輸出混合氣體常數
Text6(3).Text = dens '輸出混合氣體密度
Text6(4).Text = u & "*10^-6" '輸出動力粘度系數
Text6(5).Text = Wm_m
For I = 1 To 6
Text1(I - 1).Text = test1(I)
Text2(I - 1).Text = test2(I)
Text3(I - 1).Text = test3(I)
If Val(test2(I)) = 0 Then
Text2(I - 1) = ""
Text3(I - 1) = ""
Text1(I - 1) = ""
End If
Next I
MDIForm1.txtInletDensity.Text = Text6(3).Text
MDIForm1.txtAdbIndex.Text = Text6(0).Text
End Sub
Private Sub Command2_Click() '清空濕度和進口參數列表
Text4.Text = ""
Text5.Text = ""
Text7(0).Text = ""
Text7(1).Text = ""
Text7(2).Text = ""
Text7(3).Text = ""
Text8(0).Text = ""
Text8(1).Text = ""
For I = 1 To 6
Text6(I - 1).Text = ""
Text1(I - 1).Text = test1(I)
Text2(I - 1).Text = test2(I)
Text3(I - 1).Text = test3(I)
Next I
For I = 1 To 6
If Val(test2(I)) = 0 Then
Text1(I - 1) = ""
Text2(I - 1) = ""
Text3(I - 1) = ""
End If
Next I
End Sub
Private Sub Command3_Click() '清空混合氣體種類和體積百分含量
For I = 0 To 5
Text1(I).Text = ""
Text2(I).Text = ""
Text3(I).Text = ""
Text6(I).Text = ""
test1(I + 1) = ""
test2(I + 1) = ""
test3(I + 1) = ""
Next I
flag = 0
End Sub
Private Sub Command4_Click()
If Text7(0).Text = "" And Text7(1).Text = "" And Text7(2).Text = "" And Text7(3).Text = "" Then '程序初始化
p = MDIForm1.txtInletPressure.Text
Text7(0).Text = p
Text7(1).Text = p * 10 ^ (-6) '壓力單位由Pa轉化為Mpa
Text7(2).Text = (p * 10 ^ -4) / 9.8 '壓力單位由Pa轉化為公斤力
Text7(3).Text = p / 100000
ElseIf Text7(0).Text <> "" Then '如果輸入壓力單位為Pa
p = Val(Text7(0).Text)
Text7(1).Text = p * 10 ^ (-6) '壓力單位由Pa轉化為Mpa
Text7(2).Text = (p * 10 ^ -4) / 9.8 '壓力單位由Pa轉化為公斤力
Text7(3).Text = p / 100000 '壓力單位由Pa轉化為巴
ElseIf Text7(1).Text <> "" Then '如果輸入壓力單位為Mpa
p = Val(Text7(1).Text) * 10 ^ 6
Text7(0).Text = p
Text7(2).Text = (p * 10 ^ -4) / 9.8 '壓力單位由Pa轉化為公斤力
Text7(3).Text = p / 100000 '壓力單位由Pa轉化為巴
ElseIf Text7(2).Text <> "" Then '如果輸入壓力為公斤力
p = Val(Text7(2).Text) * 98000
Text7(0).Text = p
Text7(1).Text = p * 10 ^ -6 '壓力單位由Pa轉化為MPa
Text7(3).Text = p / 100000 '壓力單位由Pa轉化為巴
ElseIf Text7(3).Text <> "" Then '如果輸入壓力為巴
p = Val(Text7(3).Text) * 100000
Text7(0).Text = p
Text7(1).Text = p * 10 ^ -6 '壓力單位由巴轉化為MPa
Text7(2).Text = (p * 10 ^ -4) / 9.8 '壓力單位由巴轉化為公斤力
End If
If Text8(0).Text = "" And Text8(1).Text = "" Then
T = Val(MDIForm1.txtInletTemp.Text)
Text8(0).Text = T
Text8(1).Text = Val(MDIForm1.txtInletTemp.Text) - 273.15
ElseIf Text8(0) <> "" Then
T = Val(Text8(0).Text)
Text8(1).Text = T - 273.15
ElseIf Text8(1) <> "" Then
T = Val(Text8(1).Text) + 273.15
Text8(0).Text = T
End If
u = viscous(T) '插值產生動力粘度系數,認為僅于溫度有關
ps = pressure(T, pa, ta) '插值產生對應于溫度T的飽和水蒸氣壓力
If Option1.Value = True Then
Else
If Option3.Value = True Or Option4.Value = True Then
If Text4.Text = "" And Text5.Text = "" Then
MsgBox "請輸入濕度", vbCritical, "錯誤"
Command4.Enabled = True
Exit Sub
Else
If Val(Text4.Text) > 100 Or Val(Text5.Text) > 100 Or Val(Text4.Text) < 0 Or Val(Text5.Text) < 0 Then
MsgBox "輸入數值無效", vbCritical, "請重新輸入"
Exit Sub
Else
End If
End If
Else
If Option3.Value = False Or Option4.Value = False Then
MsgBox "請選擇濕度類型", vbCritical, "錯誤"
Exit Sub
End If
End If
End If
List1.Enabled = True
End Sub
Private Sub Command7_Click()
Dim hum_r As Single '相對濕度
Dim hum_a As Single '絕對濕度
Dim c_vol(1 To 6) As Single '體積百分比
Dim emi(1 To 6) As Single
Dim k As Single '絕熱指數
For I = 1 To 6
c_vol(I) = 0
emi(I) = 0
test2(I) = Val(Text2(I - 1).Text)
Next I
hum_r = 0
hum_a = 0
Sumcontent = 0 'Sumcontent初始化
Wm_m = 0
Cp = 0
Text5.Enabled = True '**************************\
For I = 0 To 5 '檢查體積百分含量的填寫錯誤
If Text1(I).Text = "" And Text2(I).Text <> "" Then
MsgBox "輸入不對應", vbCritical, "錯誤"
Exit Sub
End If
If Text2(I).Text = "" And Text1(I).Text <> "" Then
MsgBox "請輸入" & Text1(I).Text & "體積含量", vbCritical, "錯誤"
Exit Sub
End If
Sumcontent = Sumcontent + Val(Text2(I).Text)
Next I
If Sumcontent > 100.5 Or Sumcontent < 99.5 Then '檢查含量
MsgBox "輸入總含量有誤,請重新輸入!", vbCritical, "錯誤"
'For I = 0 To 5
'Text1(I).Text = ""
'Text2(I).Text = ""
'Text3(I).Text = ""
'Next I
'flag = 0
Exit Sub
Else
End If
End Sub
Public Sub List1_Click()
Dim gasname As String
Dim Cp2() As Single
Call init
ReDim Cp2(1 To sum)
gasname = items(List1.ListIndex + 1)
' Case 0
' gasname = "氧氣"
' Case 1
' gasname = "氬氣"
' Case 2
' gasname = "一氧化碳"
' Case 3
' gasname = "二氧化碳"
' Case 4
' gasname = "氮氣"
' Case 5
' gasname = "氫氣"
' Case 6
' gasname = "空氣"
' Case 7
' gasname = "甲烷"
' Case 8
' gasname = "二氧化硫"
' Case 9
' gasname = "硫化氫"
' Case 10
' gasname = "乙烷"
' End Select
If flag >= 6 Then
MsgBox "氣體種類已經選滿", vbCritical, "錯誤"
Exit Sub
End If
Text1(flag).Text = gasname
test1(flag + 1) = gasname
Text3(flag).Text = molweight(List1.ListIndex)
test3(flag + 1) = molweight(List1.ListIndex)
Cp2(flag + 1) = Cpi(List1.ListIndex + 1)
Cp1(flag + 1) = Cp2(flag + 1)
For I = 0 To flag - 1
If Text1(I).Text = Text1(flag).Text Then
MsgBox "重復選擇", vbCritical, "錯誤"
Text1(flag) = ""
Text3(flag) = ""
flag = flag - 1
GoTo error '跳轉到 error
End If
Next I
error:
flag = flag + 1
End Sub
Private Sub Option1_Click()
Option1.Value = True
Option2.Value = False
Option3.Enabled = False
Option4.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Option2_Click()
Option1.Value = False
Option2.Value = True
Option3.Value = False
Option4.Value = False
Option3.Enabled = True
Option4.Enabled = True
Text4.Enabled = False
Text5.Enabled = False
Text4.Text = ""
Text5.Text = ""
End Sub
Private Sub Option3_Click()
Text5.Text = ""
Text4.Enabled = True
Text5.Enabled = False
End Sub
Private Sub Option4_Click()
Text4.Text = ""
Text5.Enabled = True
Text4.Enabled = False
End Sub
Private Sub Text7_Change(Index As Integer)
If flag1 = True Then
For I = 0 To 3
Text7(I) = ""
Next I
End If
flag1 = False
End Sub
Private Sub Text7_GotFocus(Index As Integer)
If Text7(0).Text = "" And Text7(1).Text = "" And Text7(2).Text = "" And Text7(3).Text = "" Then
flag1 = False
Else
flag1 = True
End If
End Sub
Private Sub Text8_GotFocus(Index As Integer)
If Text8(0).Text = "" And Text8(1).Text = "" Then
flag2 = False
Else
flag2 = True
End If
End Sub
Private Sub Text7_LostFocus(Index As Integer)
flag1 = False
End Sub
Private Sub Text8_Change(Index As Integer)
If flag2 = True Then
For I = 0 To 1
Text8(I) = ""
Next I
End If
flag2 = False
End Sub
Private Sub Text8_LostFocus(Index As Integer)
flag2 = False
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -