title: Double Click Event on the items of the ListBox of a Userform VBA
body: <p>I am trying to do a small "save as" interface on excel using vba, so that I can save some of the information that i have putted in my sheet in another sheet. I am almost done with it and it looks like this: <a href="https://i.stack.imgur.com/XBKSj.png" rel="nofollow noreferrer">click here to see my Save As interface</a></p>
  
  <p>My problem is that I want to put an event on double clicking on one of the elements of my list, let's say SoCs2. On double click, I want the string "SoCs2" to appear in the textbox below. </p>
  
  <p>I tried something like that:</p>
  
  <pre><code>Private Sub Listbox1_BeforeDoubleClick(ByVal Cancel As MSForms.ReturnBoolean)
  
  With Me.ListBox1
       For i = 0 To .ListCount - 1
         If .Selected(i) Then
           Me.TextBox1.Value = .List(i, 0)
           Exit For
         End If
       Next
  End With
  
  End Sub
  </code></pre>
  
  <p>My ListBox is called ListBox1 and my TextBox is called TextBox1.
  Unfortunately, this code doesn't work: when I double click on one of the items of my ListBox, it does absolutely nothing.
  Can somebody help me with this issue ? </p>