VB 编程问题,请求帮助

来源:百度知道 编辑:UC知道 时间:2024/05/30 01:18:02
我想实现的功能是:
如果选combo1.text中的1600KVA以上的变压器"或"1600 KVA以下的变压器" 时都跳到Command1_Click 执行,请问我上面那个combo1_Change 代码错哪了?该怎么填

注意:前提是我必须先选 combo1下的内容后
点Command1才能运行计算,不选的话先提示用户选择,不执行下面的计算
最好请运行下,能通过的才行

代码如下:

Private Sub combo1_Change()
If Combo1.Text = "1600KVA以上的变压器" Then
Command1_Click
Else
MsgBox "请选择变压器容量"
End If
End Sub

Private Sub Command1_Click()
Dim X As Single, Y As Single, z As Single
Dim r As Double
Dim rmax As Double
Dim rmin As Double
Dim p As Double
X = Val(Text1.Text)
Y = Val(Text2.Text)
z = Val(Text3.Text)
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) And IsNumeric(Text3.Text) Then
If X < Y Then
t = X
X = Y
Y = t
End If
If X < z Then
t = X
X = z
z = t
End If
If Y < z Then
t = Y
Y = z
z = t
End If

Private Sub Command1_Click()
Dim X As Single, Y As Single, z As Single
Dim r As Double
Dim rmax As Double
Dim rmin As Double
Dim p As Double
X = Val(Text1.Text)
Y = Val(Text2.Text)
z = Val(Text3.Text)
If Combo1.Text = "1600KVA以上的变压器" Then
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) And IsNumeric(Text3.Text) Then
If X < Y Then
t = X
X = Y
Y = t
End If
If X < z Then
t = X
X = z
z = t
End If
If Y < z Then
t = Y
Y = z
z = t
End If
Else
MsgBox "请输入数值"
End If
rmax = Str(X)
rmin = Str(z)
If X + Y + z <> 0 Then '验证有效性
p = (X + Y + z) / 3
r = (rmax - rmin) / p
Text4.Text = r
End If
Else
MsgBox "请选择变压器容量"
End If
End Sub

Private Sub Form_Load()
Combo1.AddItem "1600KVA以上的变压器"
Co