念珠菌阳性什么意思:VB代码错误

来源:百度文库 编辑:神马品牌网 时间:2024/04/19 18:22:52
这是个计算器代码

Dim x(4) As Double
Private Sub Command1_Click()
Text1.Text = 1
End Sub

Private Sub Command10_Click()
Text1.Text = 0
End Sub

Private Sub Command13_Click()
x(1) = y
End Sub

Private Sub Command14_Click()
x(2) = y
End Sub

Private Sub Command15_Click()
x(3) = y
End Sub

Private Sub Command16_Click()
x(4) = y
End Sub

Private Sub Command17_Click()
x(0) = y
If x(1) <> 0 Then
Text1.Text = x(1) + x(0)
ElseIf x(2) <> 0 Then
Text1.Text = x(2) - x(0)
ElseIf x(3) <> 0 Then
Text1.Text = x(3) * x(0)
ElseIf x(4) <> 0 Then
Text1.Text = x(4) / x(0)
End If
End Sub

Private Sub Command2_Click()
Text1.Text = 2
End Sub

Private Sub Command3_Click()
Text1.Text = 3
End Sub

Private Sub Command4_Click()
Text1.Text = 4
End Sub

Private Sub Command5_Click()
Text1.Text = 5
End Sub

Private Sub Command6_Click()
Text1.Text = 6
End Sub

Private Sub Command7_Click()
Text1.Text = 7
End Sub

Private Sub Command8_Click()
Text1.Text = 8
End Sub

Private Sub Command9_Click()
Text1.Text = 9
End Sub
Public Sub Form_Load()
x(0) = Val(0)
x(1) = Val(0)
x(2) = Val(0)
x(3) = Val(0)
x(4) = Val(0)
y = Val(Text1.Text)
Text1.Enabled = False
Text1.Text = 0
Command1.Caption = 1
Command1.FontSize = 17
Command2.Caption = 2
Command2.FontSize = 17
Command3.Caption = 3
Command3.FontSize = 17
Command4.Caption = 4
Command4.FontSize = 17
Command5.Caption = 5
Command5.FontSize = 17
Command6.Caption = 6
Command6.FontSize = 17
Command7.Caption = 7
Command7.FontSize = 17
Command8.Caption = 8
Command8.FontSize = 17
Command9.Caption = 9
Command9.FontSize = 17
Command10.Caption = 0
Command10.FontSize = 17
Command11.Caption = "C"
Command11.FontSize = 17
Command11.Cancel = True
Command12.Caption = "."
Command12.FontSize = 17
Command13.FontSize = 17
Command14.FontSize = 17
Command15.FontSize = 17
Command16.FontSize = 17
Command17.FontSize = 17
End Sub
Private Sub command12_click()
MsgBox "此功能尚未开放,预计下一版本将制作!", , "温馨提示"
End Sub

有错误,请帮忙看看,等号点击无效啊~

看一下这里,Y是一个空变量,也就是0
Private Sub Command13_Click()
x(1) = y
End Sub

Private Sub Command14_Click()
x(2) = y
End Sub

Private Sub Command15_Click()
x(3) = y
End Sub

Private Sub Command16_Click()
x(4) = y
End Sub

你给x(1 to 4)都输入0
而这里自然没一个条件句通得过
Private Sub Command17_Click()
x(0) = y
If x(1) <> 0 Then
Text1.Text = x(1) + x(0)
ElseIf x(2) <> 0 Then
Text1.Text = x(2) - x(0)
ElseIf x(3) <> 0 Then
Text1.Text = x(3) * x(0)
ElseIf x(4) <> 0 Then
Text1.Text = x(4) / x(0)
End If
End Sub

修改建议:
Private Sub Command14_Click()
x(2) =VAL(TEXT1.TEXT)
End Sub
COMMAND15,16,13都一样

Private Sub Command17_Click()
x(0) =VAL(TEXT1.TEXT)
If x(1) <> 0 Then
Text1.Text = x(1) + x(0)
ElseIf x(2) <> 0 Then
Text1.Text = x(2) - x(0)
ElseIf x(3) <> 0 Then
Text1.Text = x(3) * x(0)
ElseIf x(4) <> 0 Then
IF X(0)<>0 THEN Text1.Text = x(4) / x(0)
End If
End Sub

应该就可以了