I have 3 textboxes on a form (txt1,txt2,txt3)
I am using an event handler (EnterHandler) to handle each textbox's Enter
event for Validation.
In the EnterHandler for txt3 I will validate that txt2 contains a Y and if not I will set the focus back to txt2.
The focus goes to txt2 but why does the Enter event get invoked twice for txt2. ?
Private Sub EnterHandler(ByVal sender As Object, ByVal e As System.EventArgs) Handles txt1.Enter, txt2.Enter, txt3.Enter
Debug.Print("ENTER " & sender.name)
Select Case sender.name
Case "txt3"
If txt2.Text <> "Y" Then
MsgBox("txt2 must be Y")
txt2.Focus()
End If
End Select
End Sub
Immediate Window Output
ENTER txt1
ENTER txt2
ENTER txt3
ENTER txt2
ENTER txt2
I am using an event handler (EnterHandler) to handle each textbox's Enter
event for Validation.
In the EnterHandler for txt3 I will validate that txt2 contains a Y and if not I will set the focus back to txt2.
The focus goes to txt2 but why does the Enter event get invoked twice for txt2. ?
Private Sub EnterHandler(ByVal sender As Object, ByVal e As System.EventArgs) Handles txt1.Enter, txt2.Enter, txt3.Enter
Debug.Print("ENTER " & sender.name)
Select Case sender.name
Case "txt3"
If txt2.Text <> "Y" Then
MsgBox("txt2 must be Y")
txt2.Focus()
End If
End Select
End Sub
Immediate Window Output
ENTER txt1
ENTER txt2
ENTER txt3
ENTER txt2
ENTER txt2