关于焦点的问题

xuco 2003-01-06 11:15:53
看下面代码:
Private Sub Text1_LostFocus()
If Len(Text1.Text) <> 4 Then
MsgBox "fdsfds"
End If
Text1.SetFocus
End Sub

Private Sub Text2_LostFocus()
If Len(Text2.Text) <> 4 Then
MsgBox "lost focus"
End If
Text2.SetFocus
End Sub
运行后焦点在第一个文本框,在第一个文本框输入字符,若字符不等于4,当我点第二个文本框后,就弹出text1失去焦点的警告窗口,我点了确定后,若text2里的字符也不等于4,又弹出text2失去焦点的警告窗口,我点了确定后,又弹出text1失去焦点的警告窗口,如此死循环。怎么解决,请高手指教,谢谢
...全文
22 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
of123 2003-01-06
  • 打赏
  • 举报
回复
Private Sub Text1_Validate(byval cancel as boolean)
If Len(Text1.Text) <> 4 Then
MsgBox "fdsfds"
cancel = true
End If
End Sub

Private Sub Text2_Validate(byval cancel as boolean)
If Len(Text2.Text) <> 4 Then
MsgBox "fdsfds"
cancel = true
End If
End Sub

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧