vb 判断两个数值的大小
三个文本框一个按钮要求1.在text1.text和text2.text中输入两个数值2.点击按钮,先判断输入的是否为数值,否则给出警告3.在点按钮,判断两个数值是否相等,...
三个文本框 一个按钮
要求
1.在text1.text和text2.text中输入两个数值
2.点击按钮,先判断输入的是否为数值,否则给出警告
3.在点按钮,判断两个数值是否相等,否则给出警告
4.在text3.text中输出较小的那个数值
下面是我的代码, 不知错在何处 ,怎样修改 ,望高手指点。
Private Sub Command1_Click()
Dim a As Double, b As Double
Let a = Val(Text1.Text) And b = Val(Text2.Text)
If Not IsNumeric(a) And Not IsNumeric(b) Then
MsgBox ("请输入数值!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
ElseIf a = b Then
MsgBox ("请输入两个不相同的数值!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
ElseIf a > b Then
Text3.Text = b
Else
Text3.Text = a
End If
End Sub 展开
要求
1.在text1.text和text2.text中输入两个数值
2.点击按钮,先判断输入的是否为数值,否则给出警告
3.在点按钮,判断两个数值是否相等,否则给出警告
4.在text3.text中输出较小的那个数值
下面是我的代码, 不知错在何处 ,怎样修改 ,望高手指点。
Private Sub Command1_Click()
Dim a As Double, b As Double
Let a = Val(Text1.Text) And b = Val(Text2.Text)
If Not IsNumeric(a) And Not IsNumeric(b) Then
MsgBox ("请输入数值!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
ElseIf a = b Then
MsgBox ("请输入两个不相同的数值!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
ElseIf a > b Then
Text3.Text = b
Else
Text3.Text = a
End If
End Sub 展开
展开全部
Private Sub Command1_Click()
Dim a As Double, b As Double
Let a = Val(Text1.Text): b = Val(Text2.Text)'你的代码这里不要用and,要用冒号
If Not IsNumeric(Text1) And Not IsNumeric(Text2) Then'这里判断数值,要把a,b换成text1,text2,因为上面已经把a,b转换成数值了,所以这里是a,b的话肯定都是数值!!
MsgBox ("请输入数值!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
ElseIf a = b Then
MsgBox ("请输入两个不相同的数值!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
ElseIf a > b Then
Text3.Text = b
Else
Text3.Text = a
End If
End Sub
Dim a As Double, b As Double
Let a = Val(Text1.Text): b = Val(Text2.Text)'你的代码这里不要用and,要用冒号
If Not IsNumeric(Text1) And Not IsNumeric(Text2) Then'这里判断数值,要把a,b换成text1,text2,因为上面已经把a,b转换成数值了,所以这里是a,b的话肯定都是数值!!
MsgBox ("请输入数值!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
ElseIf a = b Then
MsgBox ("请输入两个不相同的数值!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
ElseIf a > b Then
Text3.Text = b
Else
Text3.Text = a
End If
End Sub
展开全部
Private Sub Command1_Click()
Dim a As Double, b As Double
Let a = Val(Text1.Text) : b = Val(Text2.Text) '帮你去掉了废话 因为val已经是将数据数字化了·所以不用检测是否为数字
If a = b Then
MsgBox ("请输入两个不相同的数值!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
ElseIf a > b Then
Text3.Text = b
Else
Text3.Text = a
End If
End Sub
Dim a As Double, b As Double
Let a = Val(Text1.Text) : b = Val(Text2.Text) '帮你去掉了废话 因为val已经是将数据数字化了·所以不用检测是否为数字
If a = b Then
MsgBox ("请输入两个不相同的数值!")
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
ElseIf a > b Then
Text3.Text = b
Else
Text3.Text = a
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询