VB的一个简单问题

来源:百度知道 编辑:UC知道 时间:2024/05/13 14:10:00
很简单的一个计算器,2个或者3个文本框..一个按钮....
我想弄成点击按纽计算的时候文本框里空的时候没任何反映..本来我加了个msgbox语句弹出来个提示框,但觉得这样太不美观了...只要没反映就行了...大家帮帮忙...
看不懂你们给我的东西应该放哪...下面是我之前的代码!!!
Private Sub Command1_Click()
Dim a As Single, b As Single, c As Single, _
d As Single, e As Single
If Not IsNumeric(Text1.Text) Then
MsgBox "输入不合法,必须输入数字", 48, "警告"
Exit Sub
End If
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
e = Val(Text5.Text)
e = (2*b - d * a ) / (c * 500)
Text1.Text = a
Text2.Text = b
Text3.Text = c
Text4.Text = d
Text5.Text = e
Text5.Text = Format(Text5.Text, "0.000")

End Sub

Private Sub Command1_Click()
Dim a!, b!, c!, d!, e!
If IsNumeric(Text1) Then
a = Val(Text1)
b = Val(Text2)
c = Val(Text3)
d = Val(Text4)
e = Val(Text5)
e = (2 * b - d * a) / (c * 500)
Text1 = a
Text2 = b
Text3 = c
Text4 = d
Text5 = Format(e, "0.000")
End If
End Sub
'希望能对你有帮助~

if textbox1.text<>"" then
执行计算
end if

if textbox.text<>"" then
执行操作
end if