这个计算器要怎么编写VB程序?
7个回答
展开全部
这里的要点是防止发生错误。
假设你的加、减、乘、除按钮分别是Command1、Command2、Command3、Command4,那么代码如下:
Private Sub Command1_Click()
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) Then
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End If
End Sub
Private Sub Command2_Click()
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) Then
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End If
End Sub
Private Sub Command3_Click()
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) Then
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End If
End Sub
Private Sub Command4_Click()
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) Then
If Val(Text2.Text) <> 0 Then
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End If
End If
End Sub
假设你的加、减、乘、除按钮分别是Command1、Command2、Command3、Command4,那么代码如下:
Private Sub Command1_Click()
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) Then
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End If
End Sub
Private Sub Command2_Click()
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) Then
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End If
End Sub
Private Sub Command3_Click()
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) Then
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End If
End Sub
Private Sub Command4_Click()
If IsNumeric(Text1.Text) And IsNumeric(Text2.Text) Then
If Val(Text2.Text) <> 0 Then
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End If
End If
End Sub
展开全部
Private Sub Command1_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a + b
End Sub
Private Sub Command2_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a - b
End Sub
Private Sub Command3_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a * b
End Sub
Private Sub Command4_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a / b
End Sub
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a + b
End Sub
Private Sub Command2_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a - b
End Sub
Private Sub Command3_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a * b
End Sub
Private Sub Command4_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
Text3.Text = a / b
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Text3 = Text1 + Text2
End Sub
Private Sub Command2_Click()
Text3 = Text1 - Text2
End Sub
Private Sub Command3_Click()
Text3 = Text2 * Text1
End Sub
Private Sub Command4_Click()
Text3 = Text1 / Text2
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Text3 = Text1 + Text2
End Sub
Private Sub Command2_Click()
Text3 = Text1 - Text2
End Sub
Private Sub Command3_Click()
Text3 = Text2 * Text1
End Sub
Private Sub Command4_Click()
Text3 = Text1 / Text2
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这个太简单 我这个复杂点
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-10-22
展开全部
连基础的计算器不会编 C语言学的烂啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
白学过计算机了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询