关于VB计算器文本框里如果为空代码

来源:百度知道 编辑:UC知道 时间:2024/05/27 00:07:10
Private Sub Command1_Click()
If Val(Text2.Text) = 0 Then
MsgBox "除数不可以为0"
Else
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End If
End Sub
这段代码是为除数为0的时候点计算出现提示,如果T1 T2为空的时候重新出一个提示,该怎么编代码啊

Private Sub Command1_Click()
if len(text1.text)<1 then
msgbox"被除数不能为空"
text1.setfocus
end if
if len(text2.text)<1 then
msgbox"除数不能为空"
text2.setfoces
end if
If Val(Text2.Text) = 0 Then
MsgBox "除数不可以为0"
Else
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End If
End Sub

Private Sub Command1_Click()
if len(text1.text)<1 then
msgbox"被除数不能为空"
end sub '必须在添加数据后才能运行
elseif len(text2.text)<1 then
msgbox"除数不能为空"
end sub '必须在添加数据后才能运行
end if
If Val(Text2.Text) = 0 Then
MsgBox "除数不可以为0"
end sub '必须在添加数据后才能运行
Else
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End If
End Sub

刚刚就和你说了你的是VB有问题,你怎么还上来问要不要我写一个给你

我晕