A question about textboxes

  • Thread starter Thread starter abxy
  • Start date Start date
A

abxy

Hi all,

in the userforms i've created, I've always had a user put data into
textbox and then click a command button to do whatever the comman
button does.

However, In the userform that i'm creating right now, i'd like for th
user to put data into the textbox and just press enter and have m
operations carried out instead of having to click a command button. Ho
can this be done?

thanks for the help :
 
You can use the keydown event to check for an enter.

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger
ByVal Shift As Integer)
MsgBox KeyCode
If KeyCode = 13 Then
'Your code here
End If
End Sub

You may also want to check for a Tab (KeyCode=9) if they would ever ta
out. Also might need to use TextBox1_Exit event if they mouse out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top