First time I'm posting. I looked around for a thread on this topic and couldn't find one.
I am using Microsoft Visual Basic 6.5 and trying to trap for when I press the returnKey or enterKey while in a textbox. The following code will run the first message only when I use the EnterKey to enter the txtEnSecondTerm textbox but not when I press the EnterKey when I'm already in the textbox.
Private Sub txtEnSecondTerm_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
MsgBox "You clicked on: " & KeyAscii
Else
MsgBox "You didn't click on 13."
End If
End Sub
I have Key Preview = Yes, but I need to do that when I am trying to trap from within a textbox and not from form?
I am using Microsoft Visual Basic 6.5 and trying to trap for when I press the returnKey or enterKey while in a textbox. The following code will run the first message only when I use the EnterKey to enter the txtEnSecondTerm textbox but not when I press the EnterKey when I'm already in the textbox.
Private Sub txtEnSecondTerm_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
MsgBox "You clicked on: " & KeyAscii
Else
MsgBox "You didn't click on 13."
End If
End Sub
I have Key Preview = Yes, but I need to do that when I am trying to trap from within a textbox and not from form?