程式只能運行到If Option9.Value 而且text.16 顯示不了運算結果

Private Sub Command1_Click()
Dim p As Double, n1 As Double, i As Double, Ka As Double, Pca As Double
If Text1.Text = "" Or Val(Text1.Text) < 0 Then MsgBox "請輸入正確的功率,重試!":
If Text2.Text = "" Or Val(Text2.Text) < 0 Then MsgBox "請輸入正確的帶輪轉速,重試!":
If Text3.Text = "" Or Val(Text3.Text) < 0 Then MsgBox "請輸入正確的傳動比,重試!":
If Option8.Value = False And Option9.Value = False Then MsgBox "啟動情況請選擇一項,重試!":
If Option5.Value = False And Option6.Value = False And Option7.Value = False Then MsgBox "每天作業小時數請選擇一項,重試!":
If Option1.Value = False And Option2.Value = False And Option3.Value = False And Option4.Value = False Then MsgBox "載荷變動情況請選擇一項,重試!":
p = Val(Text1.Text)
n1 = Val(Text2.Text)
i = Val(Text3.Text)
Ka = Val(Text4.Text)
If Option8.Value = True And Option5.Value = True And Option1.Value = True Then
Ka = 1
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option5.Value = True And Option2.Value = True Then
Ka = 1.1
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option5.Value = True And Option3.Value = True Then
Ka = 1.2
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option5.Value = True And Option4.Value = True Then
Ka = 1.3
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option6.Value = True And Option1.Value = True Then
Ka = 1.1
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option6.Value = True And Option2.Value = True Then
Ka = 1.2
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option6.Value = True And Option3.Value = True Then
Ka = 1.3
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option6.Value = True And Option4.Value = True Then
Ka = 1.4
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option7.Value = True And Option1.Value = True Then
Ka = 1.2
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option7.Value = True And Option2.Value = True Then
Ka = 1.3
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option7.Value = True And Option3.Value = True Then
Ka = 1.4
Text4.Text = Str(Ka)
End If
If Option8.Value = True And Option7.Value = True And Option4.Value = True Then
Ka = 1.5
Text4.Text = Str(Ka)
If Option9.Value = True And Option5.Value = True And Option1.Value = True Then
Ka = 1.1
Text4.Text = Str(Ka)
End If
If Option9.Value = True And Option5.Value = True And Option2.Value = True Then
Ka = 1.2
Text4.Text = Str(Ka)
End If
If Option9.Value = True And Option5.Value = True And Option3.Value = True Then
Ka = 1.4
Text4.Text = Str(Ka)
End If
If Option9.Value = True And Option5.Value = True And Option4.Value = True Then
Ka = 1.5
Text4.Text = Str(Ka)
End If
If Option9.Value = True And Option6.Value = True And Option1.Value = True Then
Ka = 1.2
Text4.Text = Str(Ka)
End If
If Option9.Value = True And Option6.Value = True And Option2.Value = True Then
Ka = 1.3
Text4.Text = Str(Ka)
End If
If Option9.Value = True And Option6.Value = True And Option3.Value = True Then
Ka = 1.5
Text4.Text = Str(Ka)
End If
If Option2.Value = True And Option6.Value = True And Option4.Value = True Then
Ka = 1.6
Text4.Text = Str(Ka)
End If
If Option9.Value = True And Option7.Value = True And Option1.Value = True Then
Ka = 1.3
Text4.Text = Str(Ka)
End If
If Option9.Value = True And Option7.Value = True And Option2.Value = True Then
Ka = 1.4
Text4.Text = Str(Ka)
End If
If Option9.Value = True And Option7.Value = True And Option3.Value = True Then
Ka = 1.6
Text4.Text = Str(Ka)
End If
If Option9.Value = True And Option7.Value = True And Option4.Value = True Then
Ka = 1.8
Text4.Text = Str(Ka)
End If
'Ka = Ka
'Pca = Pca
Text4.Text = Ka
Pca = Ka * p
Text16.Text = Pca
End If
End Sub
uj5u.com熱心網友回復:
懶得看這種垃圾代碼。Google VB控制元件陣列,然后重寫程式。
uj5u.com熱心網友回復:
你的 If ... End If 嵌套又搞錯了。If Option1.Value = False And Option2.Value = False And Option3.Value = False And Option4.Value = False Then MsgBox "載荷變動情況請選擇一項,重試!":
p = Val(Text1.Text)
n1 = Val(Text2.Text)
i = Val(Text3.Text)
Ka = Val(Text4.Text)
End If '這里加
Text4.Text = Ka
Pca = Ka * p
Text16.Text = Pca
' End If '這里去掉
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/120519.html
標籤:VB基礎類
上一篇:驅動編譯錯誤
