if trim(text1)="" then 'text1为空 msgbox "text1不能为空,请输入内容" text1.setfocus exit sub '强制退出该过程 else ...... end if
Private Sub text1_LostFocus() if text1.text = "" then msgbox "输入不能为空!" text1.setfocus exit sub end if End Sub
在你的程序中加入下面的代码:If Text1.text="" Then Msgbox "" Text1.Setfocus Exit Sub '或者是exit function End If
Private Sub Text1_DataChange() if text1.text = "" then msgbox "输入不能为空!" exit sub end if End Sub 加上 Private Sub text1_LostFocus() if text1.text = "" then msgbox "输入不能为空!" text1.setfocus exit sub end if End Sub 这样错误的几率会降低
很简单啊,如下:Private Sub text1_LostFocus() if text1.text = "" then msgbox "错误,输入不能为空!" text1.setfocus end if End Sub
If Trim(Text1.Text)="" then MsgBox "不能为空,请输入内容" Text1.SetFocus Exit sub '退出过程 Else ...... End If
msgbox "text1不能为空,请输入内容"
text1.setfocus
exit sub '强制退出该过程
else
......
end if
if text1.text = "" then
msgbox "输入不能为空!"
text1.setfocus
exit sub
end if
End Sub
Msgbox ""
Text1.Setfocus
Exit Sub '或者是exit function
End If
if text1.text = "" then
msgbox "输入不能为空!"
exit sub
end if
End Sub
加上
Private Sub text1_LostFocus()
if text1.text = "" then
msgbox "输入不能为空!"
text1.setfocus
exit sub
end if
End Sub
这样错误的几率会降低
if text1.text = "" then
msgbox "错误,输入不能为空!"
text1.setfocus
end if
End Sub
MsgBox "不能为空,请输入内容"
Text1.SetFocus
Exit sub '退出过程
Else
......
End If