VB求高手解答。。。 command1下的代码运行为什么不能正确输出对应的结果。
PrivateSubCommand1_Click()DimaAsInteger,bAsInteger,cAsLonga=Val(Text1.Text)b=Val(Text...
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Long
a = Val(Text1.Text)
b = Val(Text1.Text)
If Label1.Caption = "-" Then
c = a - b
Else
If Label1.Caption = "+" Then
c = a + b
Else
If Label1.Caption = "*" Then
c = a * b
Else
c = a / b
End If
End If
End If
Label2.Caption = "=" & c
End Sub
Private Sub chengfa_Click()
Label1.Caption = "*"
End Sub
Private Sub chufa_Click()
Label1.Caption = "/"
End Sub
Private Sub jiafa_Click()
Label1.Caption = "+"
End Sub
Private Sub jianfa_Click()
Label1.Caption = "-"
End Sub
Private Sub clear_Click()
Text1.Text = ""
Text2.Text = ""
Label1.Caption = ""
Label2.Caption = ""
End Sub
Private Sub quit_Click()
Unload Me
End Sub 展开
Dim a As Integer, b As Integer, c As Long
a = Val(Text1.Text)
b = Val(Text1.Text)
If Label1.Caption = "-" Then
c = a - b
Else
If Label1.Caption = "+" Then
c = a + b
Else
If Label1.Caption = "*" Then
c = a * b
Else
c = a / b
End If
End If
End If
Label2.Caption = "=" & c
End Sub
Private Sub chengfa_Click()
Label1.Caption = "*"
End Sub
Private Sub chufa_Click()
Label1.Caption = "/"
End Sub
Private Sub jiafa_Click()
Label1.Caption = "+"
End Sub
Private Sub jianfa_Click()
Label1.Caption = "-"
End Sub
Private Sub clear_Click()
Text1.Text = ""
Text2.Text = ""
Label1.Caption = ""
Label2.Caption = ""
End Sub
Private Sub quit_Click()
Unload Me
End Sub 展开
展开全部
根据你的条件判断逻辑,只要不是加减乘号,其余都归为除法运算,包括什么运算符都不点,只要点击command1也同样进行除法运算。 建议你用select case语句
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询