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

来源:百度知道 编辑:UC知道 时间:2024/05/17 06:58:36
当确定密码输入的和密码不一样时,则text3显示密码错误,我要在光标离开text文本时判断的。

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

楼上的都没什么用
看 我 的
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

Text1_LostFocus()更好~

Text1_LostFocus

''点击form的时候没反应
因为点击form的时候焦点没有变化

Private sub Text1_LostFocus()
if text1.text<>text3.text then
msgbox"错误"
end if
end sub

我把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