|
Private Sub CommandButton6_Click() '节点信息从头录入
Sheet4.Activate
For i = 1 To Node + 50
For j = 1 To 15
Sheet4.Cells(i, j) = ""
Next: Next
msg = "欢迎使用Excel矿井通风辅助系统" & Chr(10) & "" & Chr(10) & "现在开始录入节点基本参数!"
style = vbYesNo
title = "Excel矿井通风辅助系统 王岸泓 制做"
Response = MsgBox(msg, style, title)
If Response = vbNo Then GoTo 20000
Node = Sheet6.Cells(5, 4)
Clade = Sheet6.Cells(6, 4)
Sheet4.Cells(5, 2) = "节点" & Chr(10) & "编号"
Sheet4.Cells(5, 3) = "标高" & Chr(10) & "(m)"
Sheet4.Cells(5, 4) = "干球" & Chr(10) & "温度" & Chr(10) & "(℃)"
Sheet4.Cells(5, 5) = "湿球" & Chr(10) & "温度" & Chr(10) & "(℃)"
Sheet4.Cells(5, 6) = "气压" & Chr(10) & "(Pa)"
Sheet4.Cells(5, 7) = "相对" & Chr(10) & "湿度" & Chr(10) & "(Ф)"
Sheet4.Cells(5, 8) = "含湿量" & Chr(10) & "" & Chr(10) & "Kg/m3"
Sheet4.Cells(5, 9) = "节点空" & Chr(10) & "气密度" & Chr(10) & "(Kg/m3)"
Sheet4.Cells(5, 10) = "标态" & Chr(10) & "密度" & Chr(10) & "(Kg/m3)"
For i = 1 To Node
For j = 2 To 10
Select Case j
Case 2
Sheet4.Cells(5 + i, j).Activate
msg = "现在开始从第" & i & "个节点开始录入"
stytle = vbYesNo
title = "Excel矿井通风辅助系统 王岸泓 制做"
Response = MsgBox(msg, stytle, title)
If Response = vbYes Then Sheet4.Cells(5 + i, j) = i Else GoTo 20000
Case 3 '输入节点标高
300 Sheet4.Cells(5 + i, j).Activate
MMM = InputBox("请输入第" & i & "个节点的标高(m)", "Excel矿井通风辅助系统 王岸泓 制做", "节点标高")
If MMM = "" Then GoTo 20000
If MMM = "节点标高" Then
msg = "数据错误!" & Chr(10) & "" & Chr(10) & "" & Chr(10) & " 是——重新输入" & Chr(10) & "" & Chr(10) & " 否——退出"
stytle = vbYesNo + vbExclamation
title = "Excel矿井通风辅助系统 王岸泓 制做"
Response = MsgBox(msg, stytle, title)
Sheet4.Cells(5 + i, j) = ""
If Response = vbYes Then GoTo 300 Else GoTo 20000
End If
Sheet4.Cells(5 + i, j) = Round(CDbl(MMM), 2)
Case 4 '输入节点干温
400 Sheet4.Cells(5 + i, j).Activate
MMM = InputBox("请输入第" & i & "个节点的干球温度(m)", "Excel矿井通风辅助系统 王岸泓 制做", "干球温度")
If MMM = "" Then GoTo 20000
Select Case MMM
Case CDbl(MMM) < -50
msg = "数据错误!" & Chr(10) & "" & Chr(10) & "" & Chr(10) & " 是——重新输入" & Chr(10) & "" & Chr(10) & " 否——退出"
stytle = vbYesNo + vbExclamation
title = "Excel矿井通风辅助系统 王岸泓 制做"
Response = MsgBox(msg, stytle, title)
Sheet4.Cells(5 + i, j) = ""
If Response = vbYes Then GoTo 400 Else GoTo 20000
Case CDbl(MMM) > 50
msg = "数据错误!" & Chr(10) & "" & Chr(10) & "" & Chr(10) & " 是——重新输入" & Chr(10) & "" & Chr(10) & " 否——退出"
stytle = vbYesNo + vbExclamation
title = "Excel矿井通风辅助系统 王岸泓 制做"
Response = MsgBox(msg, stytle, title)
Sheet4.Cells(5 + i, j) = ""
If Response = vbYes Then GoTo 400 Else GoTo 20000
Case MMM = "干球温度"
msg = "数据错误!" & Chr(10) & "" & Chr(10) & "" & Chr(10) & " 是——重新输入" & Chr(10) & "" & Chr(10) & " 否——退出"
stytle = vbYesNo + vbExclamation
title = "Excel矿井通风辅助系统 王岸泓 制做"
Response = MsgBox(msg, stytle, title)
Sheet4.Cells(5 + i, j) = ""
If Response = vbYes Then GoTo 400 Else GoTo 20000
End Select
Sheet4.Cells(5 + i, j) = Round(CDbl(MMM), 1)
End Select
Next
Next
20000
End Sub
这是我编的一段代码。当执行后运行到 case 4 j 时,直接按回车键,出现类型不匹配的错误,反复看了n遍,也没找到原因,后来把这段用来判断条件的代码用 if 语句重新编写,也是出现同样的问题,不知哪位大侠能帮下忙?我刚学VBA。先谢谢了 |
|