VB在光标离开文本框时执行程序

当确定密码输入的和密码不一样时,则text3显示密码错误,我要在光标离开text文本时判断的。

Private Sub Text1_Change()
告诉我这个就可以了,change改成什么?
怎么大家还是不明白吗?
我是想要鼠标点击别处的时候,一楼的确对了,但是我点击form的时候没反应,在点击text2的时候才有反应。怎么回事?
二楼的,我是想要光标离开text时,不是进入窗口时,怎么会是form?

第1个回答  2009-07-12
我把2楼的改改!

'加一个text1

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X < Text1.Left Or X > Text1.Left + Text1.Width Or Y < Text1.Top Or Y > Text1.Top + Text1.Height Then
If Text1 = "" Then
Text1 = ""
Else
MsgBox "离开"
Text1 = ""
End If
End If
End Sub
第2个回答  2009-07-12
Text1_LostFocus

''点击form的时候没反应
因为点击form的时候焦点没有变化
第3个回答  2009-07-11
Private sub Text1_LostFocus()
if text1.text<>text3.text then
msgbox"错误"
end if
end sub
第4个回答  2009-07-10
楼上的都没什么用
看 我 的
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If X < Text1.Left Or X > Text1.Left + Text1.Width Or Y < Text1.Top Or Y > Text1.Top + Text1.Height Then
MsgBox "离开"
End If
End Sub本回答被网友采纳
第5个回答  2020-05-16
private
sub
form_activate()
text2.setfocus
end
sub
widebright
-
江湖少侠
七级同志,你能在form-load
事件中,给
textbox调用setfocus方法?你试过了么?你能确定不报错?
相似回答