4个回答
2013-11-17
展开全部
主要是在焦点切换时 来验证
Dim tState As Boolean '开关
Private Sub Text1_GotFocus()'获取焦点时
tState = True
End Sub
Private Sub Text2_GotFocus()'获取焦点时
tState = True
End Sub
Private Sub Text1_LostFocus()'失去焦点时
If Text1.Text = "" And tState Then
MsgBox "该项不能为空"
Text1.SetFocus
End If
tState = False
End Sub
Private Sub Text2_LostFocus()
If Text2.Text = "" And tState Then
MsgBox "该项不能为空"
Text2.SetFocus
End If
tState = False
End Sub
Dim tState As Boolean '开关
Private Sub Text1_GotFocus()'获取焦点时
tState = True
End Sub
Private Sub Text2_GotFocus()'获取焦点时
tState = True
End Sub
Private Sub Text1_LostFocus()'失去焦点时
If Text1.Text = "" And tState Then
MsgBox "该项不能为空"
Text1.SetFocus
End If
tState = False
End Sub
Private Sub Text2_LostFocus()
If Text2.Text = "" And tState Then
MsgBox "该项不能为空"
Text2.SetFocus
End If
tState = False
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐于2018-05-09
展开全部
Private Sub Timer1_Timer()
if me.TEXT1.text="" then
msgbox "TEXT内容不能为空",,"wrong"
me.text1.text="TEXT内容不能为空"
End if
End Sub
if me.TEXT1.text="" then
msgbox "TEXT内容不能为空",,"wrong"
me.text1.text="TEXT内容不能为空"
End if
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-11-17
展开全部
Private Sub Command1_Click()
If (Text1.Text = "") Then
MsgBox "内容不能为空"
End If
End Sub
If (Text1.Text = "") Then
MsgBox "内容不能为空"
End If
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-11-17
展开全部
文本框有自己的验证事件,代码如下。
Private Sub Text1_Validate(Cancel As Boolean)
If Text1.Text = "" Then
MsgBox "空"
Cancel = True
End If
End Sub
Private Sub Text1_Validate(Cancel As Boolean)
If Text1.Text = "" Then
MsgBox "空"
Cancel = True
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询