vb怎样控制一个文本框的输入数值不能是零,且不能为空

新手求教

在你使用文本框数据的过程中加入判断代码,如:
Private Sub Command1_Click()
If Len(Trim(Text1.Text)) = 0 Then
MsgBox "不能为空!"
Text1.SetFocus
Exit Sub
End If
If Trim(Text1.Text) = 0 Then
MsgBox "不能为零!"
Text1.SetFocus
Exit Sub
End If
'这里写你要执行的代码
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-03-06
if Text1.text<>0 and Text1.text<>"" then这样就行了