Home > Software engineering >  VBA can hit enter on the listbox response button click event
VBA can hit enter on the listbox response button click event

Time:09-27

Listbox1 down with the keyboard on selected items after press enter, then hit return response events give TEXTBOX2 listbox1 selected entry value assignment, then hide the listbox,

CodePudding user response:

Keypress
Keydown
Keyup
These three events?

CodePudding user response:

 Private Sub List1_KeyDown (KeyCode As an Integer, Shift the As an Integer) 
If KeyCode=vbKeyReturn Then
Text2=List1. Text
End the If
End Sub

CodePudding user response:

 Private Sub ListBox1_KeyPress (ByVal KeyAscii As MSForms. ReturnInteger) 
If (KeyAscii=vbKeyReturn) Then TextBox2. Text=ListBox1. Text
End Sub

CodePudding user response:

VBA window ListBox, support itself with the arrow keys left to change the selected items, don't have to write code to handle,
(note: to make it gains focus after, press the arrow keys to effective)
  • Related