程序只能运行到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

解决方案 »

  1.   

    懒得看这种垃圾代码。Google VB控件数组,然后重写程序。
      

  2.   

    你的 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 '这里去掉