TextBox focus 4
It just resets the Keycode to zero.
So the normal result of the enter key won't happen.
Actually you don't need to set the focus as you are already in the textbox.
So this will do the same:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If KeyCode = 13 Then
MsgBox "doing processing here"
KeyCode = 0
End If
End Sub
RBS
"Tim Coddington" wrote in message
...
Thanks. This appears to work. Will test it totally on Monday.
What does the 'KeyCode = 0' statement do?
"RB Smissaert" wrote in message
...
How about this:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
If KeyCode = 13 Then
MsgBox "doing processing here"
TextBox1.SetFocus
KeyCode = 0
End If
End Sub
RBS
"Tim Coddington" wrote in message
...
I have a userform with two option buttons and a textbox.
I want the text box to always have focus (except I need to
be able to select the check boxes) so a user can input one
string, press 'Enter' to process, and enter the next string
repeatedly. Here is the total amount of code ...
Private Sub OptionButton1_Click()
TextBox1.SetFocus
End Sub
Private Sub OptionButton2_Click()
TextBox1.SetFocus
End Sub
Every time I type something into the text box and press
'Enter', the cursor disappears from the text box and I have
to click on it (or one of the option buttons) to get it back.
Can someone tell me what is happening and how to solve it??
PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE????
|