VB中,如果text1中有数据 就让text2得到焦点,没有数据的话 则text1不失去焦点

2025-02-26 01:19:58
推荐回答(2个)
回答1:

Private Sub Text1_Change()
If Text1.Text <> "" Then
Text2.SetFocus
Else
Text1.SetFocus
End If
End Sub

Private Sub Text2_Change()
If Text2.Text <> "" Then
Text1.SetFocus
Else
Text2.SetFocus
End If
End Sub

回答2:

if text1.value<>"" then
text2.setfocus
esle
text1.setfocus
end if